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 listJul 7, 2026 19:55Victor MerckléVictor MerckléScore: 2,806Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 20:012,78536,762,33116,811,0008,537,00092,639,232stderr
2Jul 7, 2026 20:012,78534,926,70016,695,0008,652,00092,737,536stderr
3Jul 7, 2026 20:012,78735,588,87016,812,0008,558,00092,700,672stderr
4Jul 7, 2026 20:012,79435,160,84916,760,0008,670,00092,704,768stderr
5Jul 7, 2026 20:012,80635,131,75416,876,0008,665,00092,704,768stderr
6Jul 7, 2026 20:012,81535,783,19816,957,0008,660,00092,827,648stderr
7Jul 7, 2026 20:012,82235,774,84516,886,0008,803,00092,758,016stderr
8Jul 7, 2026 20:012,82535,895,44616,773,0008,937,00092,721,152stderr
9Jul 7, 2026 20:012,85135,604,53916,791,0009,156,00092,737,536stderr