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 15:02Victor MerckléVictor MerckléScore: 2,698Success
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:112,68933,256,48115,825,0008,653,00092,753,920stderr
2Sep 16, 2026 15:112,68933,179,88715,857,0008,618,00092,737,536stderr
3Sep 16, 2026 15:112,69333,992,33815,829,0008,680,00092,717,056stderr
4Sep 16, 2026 15:112,69733,279,32615,832,0008,718,00092,778,496stderr
5Sep 16, 2026 15:112,69833,381,43115,847,0008,709,00092,758,016stderr
6Sep 16, 2026 15:112,70233,362,94015,878,0008,712,00092,770,304stderr
7Sep 16, 2026 15:112,70533,371,68215,883,0008,733,00092,680,192stderr
8Sep 16, 2026 15:112,71233,467,50315,875,0008,805,00092,692,480stderr
9Sep 16, 2026 15:112,71333,574,34215,896,0008,797,00092,733,440stderr