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 10, 2026 00:01Victor MerckléVictor MerckléScore: 2,743Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 00:072,72533,732,58616,086,0008,718,00092,762,112
2Jun 10, 2026 00:072,72833,826,77416,117,0008,715,00092,762,112
3Jun 10, 2026 00:072,73533,780,76316,160,0008,737,00092,725,248
4Jun 10, 2026 00:072,73635,380,38016,153,0008,749,00092,733,440
5Jun 10, 2026 00:072,74333,921,55116,154,0008,816,00092,729,344
6Jun 10, 2026 00:072,74333,983,75616,184,0008,782,00092,745,728
7Jun 10, 2026 00:072,74533,968,57616,200,0008,787,00092,733,440
8Jun 10, 2026 00:072,75534,077,64516,217,0008,862,00092,758,016
9Jun 10, 2026 00:072,76134,156,72816,251,0008,876,00092,774,400