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 listSep 14, 2026 01:43Andrew EpsteinAndrew EpsteinScore: 6,263Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 01:486,05465,403,48538,018,00017,074,00094,392,320
2Sep 14, 2026 01:486,10165,876,06838,292,00017,232,00094,392,320
3Sep 14, 2026 01:486,13266,117,41438,717,00017,085,00094,392,320
4Sep 14, 2026 01:486,16166,457,59838,864,00017,209,00094,392,320
5Sep 14, 2026 01:486,26368,103,65840,009,00016,993,00094,392,320
6Sep 14, 2026 01:486,31467,778,98040,240,00017,225,00094,392,320
7Sep 14, 2026 01:486,37568,443,99440,950,00017,068,00094,392,320
8Sep 14, 2026 01:486,39168,454,04541,165,00016,997,00094,392,320
9Sep 14, 2026 01:486,51969,618,85342,228,00017,100,00094,392,320