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 listSep 16, 2026 14:54Victor MerckléVictor MerckléScore: 2,703Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 15:002,69633,328,34215,882,0008,660,00092,725,248stderr
2Sep 16, 2026 15:002,69733,246,81415,893,0008,658,00092,753,920stderr
3Sep 16, 2026 15:002,69833,302,90815,873,0008,685,00092,803,072stderr
4Sep 16, 2026 15:002,70133,389,75715,879,0008,705,00092,803,072stderr
5Sep 16, 2026 15:002,70333,339,18615,877,0008,724,00092,741,632stderr
6Sep 16, 2026 15:002,70634,158,75615,928,0008,702,00092,749,824stderr
7Sep 16, 2026 15:002,71234,146,39415,953,0008,734,00092,692,480stderr
8Sep 16, 2026 15:002,72134,196,27615,951,0008,812,00092,774,400stderr
9Sep 16, 2026 15:002,72233,548,11315,950,0008,828,00092,729,344stderr