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 listJun 21, 2026 00:39Victor MerckléVictor MerckléScore: 2,669Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 21, 2026 00:442,66031,674,23815,525,0008,681,00092,717,056
2Jun 21, 2026 00:442,66231,735,01715,536,0008,693,00092,721,152
3Jun 21, 2026 00:442,66633,448,25115,557,0008,706,00092,753,920
4Jun 21, 2026 00:442,66731,706,42815,582,0008,693,00092,786,688
5Jun 21, 2026 00:442,66931,899,73415,584,0008,706,00092,782,592
6Jun 21, 2026 00:442,68731,897,29015,756,0008,702,00092,758,016
7Jun 21, 2026 00:442,68831,872,52515,660,0008,803,00092,770,304
8Jun 21, 2026 00:442,69032,061,93115,691,0008,790,00092,717,056
9Jun 21, 2026 00:442,69031,907,54515,655,0008,831,00092,676,096