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

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 15:592,68833,243,01815,805,0008,659,00092,721,152stderr
2Sep 15, 2026 15:592,69133,186,80215,821,0008,676,00092,692,480stderr
3Sep 15, 2026 15:592,70233,397,49216,006,0008,584,00092,794,880stderr
4Sep 15, 2026 15:592,70634,018,17516,025,0008,601,00092,667,904stderr
5Sep 15, 2026 15:592,71233,359,22716,056,0008,629,00092,782,592stderr
6Sep 15, 2026 15:592,71234,051,91716,061,0008,622,00092,749,824stderr
7Sep 15, 2026 15:592,71533,406,90115,893,0008,821,00092,721,152stderr
8Sep 15, 2026 15:592,72034,111,87316,042,0008,719,00092,803,072stderr
9Sep 15, 2026 15:592,72334,036,05816,078,0008,702,00092,729,344stderr