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 5, 2026 17:16Victor MerckléVictor MerckléScore: 2,759Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 17:212,74034,065,90016,358,0008,582,00092,762,112
2Jun 5, 2026 17:212,74134,088,53416,090,0008,861,00092,745,728
3Jun 5, 2026 17:212,74434,284,09416,106,0008,868,00092,766,208
4Jun 5, 2026 17:212,74534,079,18416,278,0008,710,00092,774,400
5Jun 5, 2026 17:212,75934,130,65416,346,0008,765,00092,770,304
6Jun 5, 2026 17:212,76234,208,23216,325,0008,814,00092,745,728
7Jun 5, 2026 17:212,76334,218,34916,361,0008,787,00092,790,784
8Jun 5, 2026 17:212,76834,261,05116,380,0008,816,00092,717,056
9Jun 5, 2026 17:212,77434,315,56316,375,0008,876,00092,708,864