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 16, 2026 20:59Andrew EpsteinAndrew EpsteinScore: 3,972Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 21:163,94646,021,40528,246,0007,663,00092,704,768
2Sep 16, 2026 21:163,95244,592,94628,141,0007,825,00092,700,672
3Sep 16, 2026 21:163,95444,563,01227,575,0008,415,00092,766,208
4Sep 16, 2026 21:163,96544,706,58527,928,0008,160,00092,770,304
5Sep 16, 2026 21:163,97244,848,35827,802,0008,344,00092,774,400
6Sep 16, 2026 21:163,97244,778,27527,754,0008,392,00092,680,192
7Sep 16, 2026 21:163,97644,970,17427,911,0008,276,00092,774,400
8Sep 16, 2026 21:163,97744,909,72027,997,0008,202,00092,782,592
9Sep 16, 2026 21:163,98244,914,97327,965,0008,273,00092,745,728