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 listFeb 19, 2026 04:46Josu San MartinJosu San MartinScore: 4,375Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Feb 19, 2026 04:464,32968,899,81123,233,00016,162,00094,552,064
2Feb 19, 2026 04:464,35668,568,31623,786,00015,857,00094,679,040
3Feb 19, 2026 04:464,35868,255,59022,803,00016,854,00094,793,728
4Feb 19, 2026 04:464,37267,708,99723,870,00015,913,00094,756,864
5Feb 19, 2026 04:464,37566,519,48624,885,00014,931,00094,777,344
6Feb 19, 2026 04:464,38666,892,84922,949,00016,962,00094,736,384
7Feb 19, 2026 04:464,39467,594,55824,988,00014,993,00094,552,064
8Feb 19, 2026 04:464,40263,502,29422,032,00018,026,00094,552,064
9Feb 19, 2026 04:464,44465,799,48123,252,00017,186,00094,674,944