XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listAug 18, 2026 14:24Victor MerckléVictor MerckléScore: 3,696Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 18, 2026 14:303,66443,152,25316,583,00016,768,00094,396,416stderr
2Aug 18, 2026 14:303,67043,489,86116,616,00016,789,00094,396,416stderr
3Aug 18, 2026 14:303,68743,365,95116,550,00017,003,00094,396,416stderr
4Aug 18, 2026 14:303,68843,403,68116,954,00016,612,00094,396,416stderr
5Aug 18, 2026 14:303,69643,449,28016,665,00016,969,00094,396,416stderr
6Aug 18, 2026 14:303,70143,475,59516,543,00017,140,00094,396,416stderr
7Aug 18, 2026 14:303,70743,587,90616,864,00016,875,00094,396,416stderr
8Aug 18, 2026 14:303,71443,605,77116,935,00016,868,00094,396,416stderr
9Aug 18, 2026 14:303,73343,832,19816,618,00017,356,00094,396,416stderr