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 16, 2026 15:14Victor MerckléVictor MerckléScore: 2,697Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 15:192,68833,200,64515,815,0008,646,00092,774,400stderr
2Sep 16, 2026 15:192,69133,383,01015,820,0008,677,00092,733,440stderr
3Sep 16, 2026 15:192,69333,262,70615,784,0008,728,00092,753,920stderr
4Sep 16, 2026 15:192,69633,268,51215,877,0008,657,00092,770,304stderr
5Sep 16, 2026 15:192,69733,275,75215,870,0008,674,00092,696,576stderr
6Sep 16, 2026 15:192,69933,288,10615,905,0008,659,00092,688,384stderr
7Sep 16, 2026 15:192,70133,426,98315,875,0008,709,00092,758,016stderr
8Sep 16, 2026 15:192,70233,471,81515,802,0008,790,00092,758,016stderr
9Sep 16, 2026 15:192,71034,069,56215,857,0008,808,00092,794,880stderr