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 09:42Victor MerckléVictor MerckléScore: 2,873Success
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 09:482,86445,027,55117,436,0008,631,00092,721,152stderr
2Sep 15, 2026 09:482,86946,041,31217,489,0008,627,00092,692,480stderr
3Sep 15, 2026 09:482,86934,837,75117,535,0008,579,00092,778,496stderr
4Sep 15, 2026 09:482,87235,461,76917,513,0008,624,00092,725,248stderr
5Sep 15, 2026 09:482,87334,831,33117,446,0008,699,00092,753,920stderr
6Sep 15, 2026 09:482,87444,739,85417,731,0008,430,00092,733,440stderr
7Sep 15, 2026 09:482,87435,513,90017,531,0008,631,00092,684,288stderr
8Sep 15, 2026 09:482,88037,136,38317,560,0008,650,00092,721,152stderr
9Sep 15, 2026 09:482,88835,637,77417,552,0008,730,00092,778,496stderr