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 11, 2026 18:01Victor MerckléVictor MerckléScore: 2,715Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:062,69233,487,75515,663,0008,841,00092,774,400
2Jun 11, 2026 18:062,70033,542,57615,838,0008,733,00092,762,112
3Jun 11, 2026 18:062,71133,706,34415,926,0008,745,00092,758,016
4Jun 11, 2026 18:062,71133,824,35015,917,0008,756,00092,749,824
5Jun 11, 2026 18:062,71533,718,63215,959,0008,753,00092,725,248
6Jun 11, 2026 18:062,71633,701,21015,975,0008,747,00092,733,440
7Jun 11, 2026 18:062,72133,749,71315,932,0008,834,00092,807,168
8Jun 11, 2026 18:062,72533,895,56915,961,0008,844,00092,741,632
9Jun 11, 2026 18:062,73633,937,27516,054,0008,851,00092,729,344