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 listJan 18, 2026 05:59Josu San MartinJosu San MartinScore: 6,238Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 05:596,19278,028,17137,229,00019,117,00094,670,848
2Jan 18, 2026 05:596,20483,139,87435,287,00021,172,00094,781,440
3Jan 18, 2026 05:596,21182,391,57637,343,00019,176,00094,666,752
4Jan 18, 2026 05:596,23485,155,12233,839,00022,891,00094,752,768
5Jan 18, 2026 05:596,23885,541,91835,850,00020,912,00094,670,848
6Jan 18, 2026 05:596,23884,607,94136,849,00019,918,00094,785,536
7Jan 18, 2026 05:596,26382,680,30334,993,00021,996,00094,679,040
8Jan 18, 2026 05:596,49182,109,08136,041,00023,026,00094,605,312
9Jan 18, 2026 05:596,54989,273,18333,769,00025,823,00094,674,944