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 listMar 4, 2026 03:12olliecrowolliecrowScore: 10,662Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 03:1210,637118,019,31274,842,00021,953,00094,572,544
2Mar 4, 2026 03:1210,645118,123,38578,895,00017,976,00094,543,872
3Mar 4, 2026 03:1210,651120,179,26480,935,00015,987,00094,801,920
4Mar 4, 2026 03:1210,661116,811,36679,010,00018,002,00094,560,256
5Mar 4, 2026 03:1210,662121,368,22182,019,00015,003,00094,584,832
6Mar 4, 2026 03:1210,671124,824,30081,090,00016,017,00094,662,656
7Mar 4, 2026 03:1210,686122,327,64884,213,00013,033,00094,556,160
8Mar 4, 2026 03:1210,727123,753,59680,681,00016,933,00094,560,256
9Mar 4, 2026 03:1210,751124,365,31780,862,00016,971,00094,543,872