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 5, 2026 17:25Victor MerckléVictor MerckléScore: 2,733Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 17:312,72233,841,99615,933,0008,840,00092,749,824
2Jun 5, 2026 17:312,72633,902,30116,097,0008,712,00092,766,208
3Jun 5, 2026 17:312,72833,812,11915,939,0008,890,00092,762,112
4Jun 5, 2026 17:312,73033,882,49716,144,0008,701,00092,766,208
5Jun 5, 2026 17:312,73333,986,75616,153,0008,719,00092,717,056
6Jun 5, 2026 17:312,73734,048,22516,189,0008,718,00092,741,632
7Jun 5, 2026 17:312,74334,038,54316,158,0008,804,00092,758,016
8Jun 5, 2026 17:312,74634,070,34416,196,0008,801,00092,774,400
9Jun 5, 2026 17:312,75434,239,99116,230,0008,838,00092,749,824