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 listAug 19, 2026 07:40Victor MerckléVictor MerckléScore: 2,759Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 07:452,74833,418,05416,414,0008,601,00092,753,920stderr
2Aug 19, 2026 07:452,75033,463,53216,608,0008,425,00092,758,016stderr
3Aug 19, 2026 07:452,75233,470,37216,563,0008,488,00092,729,344stderr
4Aug 19, 2026 07:452,75334,145,95116,396,0008,664,00092,708,864stderr
5Aug 19, 2026 07:452,75934,146,36116,363,0008,744,00092,733,440stderr
6Aug 19, 2026 07:452,77033,529,04916,683,0008,531,00092,704,768stderr
7Aug 19, 2026 07:452,77833,608,02116,656,0008,627,00092,721,152stderr
8Aug 19, 2026 07:452,79133,867,59516,730,0008,670,00092,803,072stderr
9Aug 19, 2026 07:452,79134,373,44216,817,0008,589,00092,758,016stderr