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 17:53Victor MerckléVictor MerckléScore: 2,758Success
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 17:592,74834,003,43316,284,0008,728,00092,696,576
2Jun 11, 2026 17:592,75134,060,55516,275,0008,765,00092,696,576
3Jun 11, 2026 17:592,75234,032,45116,291,0008,754,00092,753,920
4Jun 11, 2026 17:592,75434,262,23616,317,0008,753,00092,721,152
5Jun 11, 2026 17:592,75835,301,30516,361,0008,744,00092,721,152
6Jun 11, 2026 17:592,76034,185,47616,325,0008,793,00092,643,328
7Jun 11, 2026 17:592,76534,197,50516,325,0008,841,00092,745,728
8Jun 11, 2026 17:592,77334,227,17916,629,0008,608,00092,692,480
9Jun 11, 2026 17:592,77434,245,03816,674,0008,573,00092,704,768