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 26, 2026 20:13Kevin HeaveyKevin HeaveyScore: 2,374Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 26, 2026 20:202,34131,370,71112,959,0008,346,00092,721,152
2Sep 26, 2026 20:202,35132,425,30813,018,0008,377,00092,659,712
3Sep 26, 2026 20:202,35431,179,30613,053,0008,369,00092,729,344
4Sep 26, 2026 20:202,36932,669,05613,073,0008,489,00092,733,440
5Sep 26, 2026 20:202,37432,727,01013,058,0008,549,00092,684,288
6Sep 26, 2026 20:202,38032,753,98813,014,0008,650,00092,749,824
7Sep 26, 2026 20:202,38233,949,37513,089,0008,589,00092,721,152
8Sep 26, 2026 20:202,38432,767,18713,085,0008,617,00092,704,768
9Sep 26, 2026 20:202,38632,676,08913,075,0008,638,00092,790,784