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 listAug 19, 2026 16:22Victor MerckléVictor MerckléScore: 2,399Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 16:272,38230,733,95013,098,0008,579,00092,737,536stderr
2Aug 19, 2026 16:272,39230,893,67413,030,0008,743,00092,749,824stderr
3Aug 19, 2026 16:272,39229,986,79013,175,0008,594,00092,762,112stderr
4Aug 19, 2026 16:272,39930,749,74213,084,0008,750,00092,725,248stderr
5Aug 19, 2026 16:272,39930,815,92713,034,0008,803,00092,758,016stderr
6Aug 19, 2026 16:272,40030,131,19813,192,0008,653,00092,692,480stderr
7Aug 19, 2026 16:272,40330,233,98313,190,0008,680,00092,766,208stderr
8Aug 19, 2026 16:272,41430,976,73613,247,0008,728,00092,778,496stderr
9Aug 19, 2026 16:272,41830,984,52713,221,0008,788,00092,782,592stderr