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 15, 2026 00:36Josu San MartinJosu San MartinScore: 63,762Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 00:4263,677589,598,832557,930,00021,536,00094,392,320
2Sep 15, 2026 00:4263,698589,764,899558,478,00021,174,00094,392,320
3Sep 15, 2026 00:4263,726590,070,561558,526,00021,389,00094,392,320
4Sep 15, 2026 00:4263,746590,231,928558,900,00021,195,00094,392,320
5Sep 15, 2026 00:4263,762590,870,538558,953,00021,289,00094,392,320
6Sep 15, 2026 00:4263,772590,654,220559,045,00021,285,00094,392,320
7Sep 15, 2026 00:4263,782590,670,064559,100,00021,325,00094,392,320
8Sep 15, 2026 00:4263,804590,800,002559,292,00021,333,00094,392,320
9Sep 15, 2026 00:4263,857591,335,953559,920,00021,182,00094,392,320