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 15, 2026 08:47Tomislav TunkovicTomislav TunkovicScore: 3,620Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 08:523,59741,165,93315,839,00016,895,00094,392,320
2Aug 15, 2026 08:523,60841,255,86915,961,00016,876,00094,392,320
3Aug 15, 2026 08:523,61741,277,03015,882,00017,037,00094,392,320
4Aug 15, 2026 08:523,61941,327,23315,899,00017,036,00094,392,320
5Aug 15, 2026 08:523,62041,330,40915,921,00017,024,00094,392,320
6Aug 15, 2026 08:523,62341,597,27515,900,00017,077,00094,392,320
7Aug 15, 2026 08:523,62841,551,19715,922,00017,101,00094,392,320
8Aug 15, 2026 08:523,63741,448,81816,035,00017,069,00094,392,320
9Aug 15, 2026 08:523,65441,593,00516,074,00017,182,00094,392,320