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 MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 01:08Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 01:09010,468,22701,359,0002,121,728invalid character '\n' in string literal
2Jul 6, 2026 01:09010,438,09301,365,0002,121,728invalid character '\n' in string literal
3Jul 6, 2026 01:09010,561,80501,361,0002,121,728invalid character '\n' in string literal
4Mar 11, 2026 00:023,90361,318,86218,266,00017,251,00094,670,848
5Mar 11, 2026 00:023,92659,382,01417,862,00017,862,00094,670,848
6Mar 11, 2026 00:023,92964,100,37316,884,00018,870,00094,666,752
7Mar 11, 2026 00:023,92969,137,71415,891,00019,863,00094,666,752
8Mar 11, 2026 00:023,93464,026,09813,923,00021,879,00094,666,752
9Mar 11, 2026 00:023,93665,946,45820,894,00014,924,00094,552,064
10Mar 11, 2026 00:023,94962,530,37115,971,00019,964,00094,654,464
11Mar 11, 2026 00:023,96154,076,17218,024,00018,024,00094,547,968
12Mar 11, 2026 00:023,96357,202,04518,031,00018,031,00094,670,848