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 listMar 22, 2026 21:34Dominique GarmierDominique GarmierScore: 7,535Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 17:357,47191,009,46850,987,00016,995,00094,564,352
2Mar 17, 2026 17:357,52393,310,97350,599,00017,858,00094,564,352
3Mar 21, 2026 02:137,52992,270,26358,437,00010,075,00094,687,232
4Mar 22, 2026 21:347,53296,569,95056,448,00012,096,00094,560,256
5Mar 21, 2026 02:137,53597,870,93057,475,00011,091,00094,744,576
6Mar 22, 2026 21:347,53697,000,14461,516,0007,059,00094,638,080
7Mar 17, 2026 17:357,53894,693,17358,507,00010,087,00094,539,776
8Mar 22, 2026 21:347,55897,016,89343,858,00024,919,00094,625,792
9Mar 21, 2026 02:137,56294,969,49358,838,0009,972,00094,801,920