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 14, 2026 22:08Andrew EpsteinAndrew EpsteinScore: 5,694Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 22:275,65761,706,90340,907,00010,575,00092,774,400stderr
2Sep 14, 2026 22:275,66961,822,94441,040,00010,551,00092,749,824stderr
3Sep 14, 2026 22:275,67062,501,77740,984,00010,615,00092,729,344stderr
4Sep 14, 2026 22:275,67462,730,35740,273,00011,361,00092,753,920stderr
5Sep 14, 2026 22:275,69462,834,00440,372,00011,450,00092,770,304stderr
6Sep 14, 2026 22:275,70862,942,41540,521,00011,423,00092,762,112stderr
7Sep 14, 2026 22:275,71863,026,95241,246,00010,793,00092,835,840stderr
8Sep 14, 2026 22:275,72162,360,14641,331,00010,739,00092,729,344stderr
9Sep 14, 2026 22:275,72962,442,06641,387,00010,753,00092,721,152stderr