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 08:46Victor MerckléVictor MerckléScore: 4,000Success
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 08:523,98945,019,53827,817,0008,486,00092,778,496stderr
2Sep 15, 2026 08:523,99044,949,43127,960,0008,355,00092,778,496stderr
3Sep 15, 2026 08:523,99645,623,59327,993,0008,378,00092,712,960stderr
4Sep 15, 2026 08:523,99745,108,91928,047,0008,332,00092,704,768stderr
5Sep 15, 2026 08:524,00045,699,26528,022,0008,384,00092,737,536stderr
6Sep 15, 2026 08:524,01045,147,27927,997,0008,495,00092,774,400stderr
7Sep 15, 2026 08:524,02145,429,14528,028,0008,567,00092,794,880stderr
8Sep 15, 2026 08:524,02445,565,48628,148,0008,479,00092,725,248stderr
9Sep 15, 2026 08:524,02645,327,58628,155,0008,483,00092,737,536stderr