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 MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 09:20Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 09:21010,452,77001,354,0002,117,632invalid character '\n' in string literal
2Jul 6, 2026 09:21010,466,63101,309,0002,117,632invalid character '\n' in string literal
3Jul 6, 2026 09:21010,399,6901,240,00002,117,632invalid character '\n' in string literal
4Feb 19, 2026 04:464,32968,899,81123,233,00016,162,00094,552,064
5Feb 19, 2026 04:464,35668,568,31623,786,00015,857,00094,679,040
6Feb 19, 2026 04:464,35868,255,59022,803,00016,854,00094,793,728
7Feb 19, 2026 04:464,37267,708,99723,870,00015,913,00094,756,864
8Feb 19, 2026 04:464,37566,519,48624,885,00014,931,00094,777,344
9Feb 19, 2026 04:464,38666,892,84922,949,00016,962,00094,736,384
10Feb 19, 2026 04:464,39467,594,55824,988,00014,993,00094,552,064
11Feb 19, 2026 04:464,40263,502,29422,032,00018,026,00094,552,064
12Feb 19, 2026 04:464,44465,799,48123,252,00017,186,00094,674,944