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 11, 2026 00:02Josu San MartinJosu San MartinScore: 3,934Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 11, 2026 00:023,90361,318,86218,266,00017,251,00094,670,848
2Mar 11, 2026 00:023,92659,382,01417,862,00017,862,00094,670,848
3Mar 11, 2026 00:023,92964,100,37316,884,00018,870,00094,666,752
4Mar 11, 2026 00:023,92969,137,71415,891,00019,863,00094,666,752
5Mar 11, 2026 00:023,93464,026,09813,923,00021,879,00094,666,752
6Mar 11, 2026 00:023,93665,946,45820,894,00014,924,00094,552,064
7Mar 11, 2026 00:023,94962,530,37115,971,00019,964,00094,654,464
8Mar 11, 2026 00:023,96154,076,17218,024,00018,024,00094,547,968
9Mar 11, 2026 00:023,96357,202,04518,031,00018,031,00094,670,848