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 07:55M-RochatM-RochatScore: 4,973Success
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 08:064,96355,032,24536,841,0008,324,00092,815,360
2May 18, 2026 08:064,96554,578,65236,835,0008,347,00092,700,672
3May 18, 2026 08:064,96754,236,79136,841,0008,365,00092,749,824
4May 18, 2026 08:064,97154,426,48136,890,0008,349,00092,758,016
5May 18, 2026 08:064,97354,391,41636,894,0008,368,00092,741,632
6May 18, 2026 08:064,97756,228,22136,796,0008,501,00092,737,536
7May 18, 2026 08:064,98457,207,57636,942,0008,418,00092,733,440
8May 18, 2026 08:064,98555,033,91436,938,0008,428,00092,667,904
9May 18, 2026 08:064,99554,626,37037,036,0008,425,00092,712,960