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:49Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 17, 2026 21:20Andrew Epstein109.08CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 21:22011,086,51701,166,0002,117,632invalid character '\x00' after object key:value pair
2Sep 17, 2026 21:22010,844,830927,000024,576invalid character '\x00' after object key:value pair
3Sep 17, 2026 21:22011,288,059869,000024,576invalid character '\x00' after object key:value pair
4Sep 15, 2026 00:553,92545,858,33418,573,00017,146,00094,392,320
5Sep 15, 2026 00:553,94346,065,74518,726,00017,158,00094,392,320
6Sep 15, 2026 00:553,95446,112,49218,702,00017,286,00094,392,320
7Sep 15, 2026 00:553,96646,332,00618,680,00017,412,00094,392,320
8Sep 15, 2026 00:553,98446,451,61418,540,00017,716,00094,392,320
9Sep 15, 2026 00:553,99546,894,27218,837,00017,522,00094,392,320
10Sep 15, 2026 00:553,99746,503,55018,543,00017,836,00094,392,320
11Sep 15, 2026 00:554,00046,648,29418,568,00017,841,00094,392,320
12Sep 15, 2026 00:554,09059,549,18918,750,00018,477,00094,392,320