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:02M-RochatM-RochatScore: 5,462Success
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 06:165,44758,967,71641,316,0008,259,00092,749,824
2May 18, 2026 06:165,45460,800,92241,346,0008,288,00092,745,728
3May 18, 2026 06:165,45858,830,21841,358,0008,312,00092,717,056
4May 18, 2026 06:165,45858,824,74041,362,0008,313,00092,745,728
5May 18, 2026 06:165,46258,812,19141,327,0008,384,00092,733,440
6May 18, 2026 06:165,46958,913,03941,383,0008,387,00092,778,496
7May 18, 2026 06:165,47760,142,68541,376,0008,470,00092,762,112
8May 18, 2026 06:165,48361,004,29341,460,0008,438,00092,737,536
9May 18, 2026 06:165,49561,370,43041,605,0008,402,00092,729,344