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 listJun 11, 2026 03:50Victor MerckléVictor MerckléScore: 2,879Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 03:562,83835,315,95116,945,0008,882,00092,815,360
2Jun 11, 2026 03:562,84235,618,16017,030,0008,839,00092,725,248
3Jun 11, 2026 03:562,87035,854,00917,137,0008,985,00092,762,112
4Jun 11, 2026 03:562,87236,016,69417,116,0009,024,00092,770,304
5Jun 11, 2026 03:562,87935,560,85017,137,0009,064,00092,790,784
6Jun 11, 2026 03:562,88235,466,96617,223,0009,006,00092,827,648
7Jun 11, 2026 03:562,88433,810,77717,189,0009,061,00092,774,400
8Jun 11, 2026 03:562,88836,132,19817,192,0009,094,00092,712,960
9Jun 11, 2026 03:562,89137,772,33916,599,0009,711,00092,766,208