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 4, 2026 07:07Victor MerckléVictor MerckléScore: 2,386Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 07:162,34930,122,13012,925,0008,459,00092,680,192stderr
2Sep 4, 2026 07:162,37129,953,68512,725,0008,855,00092,774,400stderr
3Sep 4, 2026 07:162,37830,067,61412,782,0008,862,00092,741,632stderr
4Sep 4, 2026 07:162,38330,779,03812,847,0008,844,00092,782,592stderr
5Sep 4, 2026 07:162,38632,083,57412,808,0008,912,00092,762,112stderr
6Sep 4, 2026 07:162,38930,346,80413,031,0008,715,00092,803,072stderr
7Sep 4, 2026 07:162,39230,139,12212,796,0008,977,00092,774,400stderr
8Sep 4, 2026 07:162,40330,269,35613,164,0008,705,00092,733,440stderr
9Sep 4, 2026 07:162,40830,974,56612,816,0009,102,00092,749,824stderr