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 listMay 18, 2026 06:57M-RochatM-RochatScore: 5,401Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 07:105,37458,176,65240,657,0008,248,00092,774,400
2May 18, 2026 07:105,39258,203,65140,770,0008,301,00092,725,248
3May 18, 2026 07:105,39658,244,88840,797,0008,310,00092,815,360
4May 18, 2026 07:105,40058,255,76340,830,0008,311,00092,749,824
5May 18, 2026 07:105,40158,324,39640,782,0008,376,00092,721,152
6May 18, 2026 07:105,40161,178,39240,828,0008,329,00092,725,248
7May 18, 2026 07:105,40360,334,80140,760,0008,409,00092,770,304
8May 18, 2026 07:105,40559,367,06340,807,0008,386,00092,753,920
9May 18, 2026 07:105,41658,568,53341,010,0008,282,00092,778,496