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 listMay 1, 2026 11:45Victor MerckléVictor MerckléScore: 4,974Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2026 11:474,93761,583,00831,952,00012,980,00094,638,080stderr
2May 1, 2026 11:474,93860,986,55932,953,00011,983,00094,650,368stderr
3May 1, 2026 11:474,94558,862,77333,004,00012,001,00094,650,368stderr
4May 1, 2026 11:474,96160,905,51432,107,00013,043,00094,650,368stderr
5May 1, 2026 11:474,97462,522,10028,805,00016,460,00094,658,560stderr
6May 1, 2026 11:474,97859,266,03434,231,00011,074,00094,642,176stderr
7May 1, 2026 11:474,98661,947,54127,229,00018,152,00094,646,272stderr
8May 1, 2026 11:474,98968,194,81827,244,00018,163,00094,646,272stderr
9May 1, 2026 11:474,98964,887,83426,231,00019,169,00094,638,080stderr