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 listAug 19, 2026 14:14Victor MerckléVictor MerckléScore: 2,430Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 14:192,40530,401,69113,392,0008,502,00092,663,808stderr
2Aug 19, 2026 14:192,41330,976,13213,444,0008,523,00092,733,440stderr
3Aug 19, 2026 14:192,41731,844,66813,471,0008,530,00092,737,536stderr
4Aug 19, 2026 14:192,41931,131,58113,506,0008,510,00092,794,880stderr
5Aug 19, 2026 14:192,43031,129,56113,556,0008,561,00092,745,728stderr
6Aug 19, 2026 14:192,43430,461,14813,585,0008,566,00092,725,248stderr
7Aug 19, 2026 14:192,43730,501,71513,512,0008,672,00092,766,208stderr
8Aug 19, 2026 14:192,43930,782,33713,551,0008,645,00092,774,400stderr
9Aug 19, 2026 14:192,45031,333,90313,616,0008,681,00092,696,576stderr