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 6, 2026 15:05Victor MerckléVictor MerckléScore: 2,746Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 6, 2026 15:102,73933,956,41016,230,0008,696,00092,729,344
2Jun 6, 2026 15:102,74234,027,17316,221,0008,736,00092,770,304
3Jun 6, 2026 15:102,74234,093,82816,048,0008,911,00092,696,576
4Jun 6, 2026 15:102,74534,110,45616,238,0008,750,00092,721,152
5Jun 6, 2026 15:102,74633,989,60716,285,0008,707,00092,741,632
6Jun 6, 2026 15:102,75234,142,60716,324,0008,722,00092,778,496
7Jun 6, 2026 15:102,76234,171,25616,336,0008,806,00092,729,344
8Jun 6, 2026 15:102,76734,262,16416,617,0008,567,00092,790,784
9Jun 6, 2026 15:102,77434,277,49416,388,0008,861,00092,778,496