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 17, 2026 13:32Victor MerckléVictor MerckléScore: 2,577Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 13:432,56832,153,42115,027,0008,349,00092,758,016stderr
2Sep 17, 2026 13:432,57032,198,66014,899,0008,496,00092,733,440stderr
3Sep 17, 2026 13:432,57532,341,87514,908,0008,531,00092,766,208stderr
4Sep 17, 2026 13:432,57732,308,96314,877,0008,579,00092,717,056stderr
5Sep 17, 2026 13:432,57732,243,01714,731,0008,728,00092,729,344stderr
6Sep 17, 2026 13:432,58032,250,12314,917,0008,570,00092,774,400stderr
7Sep 17, 2026 13:432,59033,047,74315,119,0008,452,00092,774,400stderr
8Sep 17, 2026 13:432,59532,653,42914,814,0008,804,00092,745,728stderr
9Sep 17, 2026 13:432,60032,426,75714,848,0008,814,00092,729,344stderr