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:57Victor MerckléVictor MerckléScore: 2,678Success
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 01:022,66731,727,35515,598,0008,678,00092,745,728
2Jun 21, 2026 01:022,66831,881,60715,543,0008,736,00092,749,824
3Jun 21, 2026 01:022,66831,833,85515,567,0008,718,00092,725,248
4Jun 21, 2026 01:022,67733,642,52115,627,0008,736,00092,704,768
5Jun 21, 2026 01:022,67831,999,74815,632,0008,739,00092,745,728
6Jun 21, 2026 01:022,68032,043,51615,746,0008,649,00092,721,152
7Jun 21, 2026 01:022,69031,868,04915,674,0008,813,00092,729,344
8Jun 21, 2026 01:022,69132,431,99215,673,0008,822,00092,717,056
9Jun 21, 2026 01:022,69432,112,62015,687,0008,835,00092,737,536