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 17, 2026 20:09Andrew EpsteinAndrew EpsteinScore: 3,993Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 20:233,97144,744,71927,768,0008,370,00092,782,592
2Sep 17, 2026 20:233,97344,832,70927,796,0008,359,00092,692,480
3Sep 17, 2026 20:233,97544,910,55227,969,0008,211,00092,745,728
4Sep 17, 2026 20:233,97944,914,30527,998,0008,212,00092,786,688
5Sep 17, 2026 20:233,99345,058,54028,038,0008,307,00092,782,592
6Sep 17, 2026 20:233,99845,152,58628,088,0008,302,00092,794,880
7Sep 17, 2026 20:234,17847,014,79629,091,0008,932,00092,762,112
8Sep 17, 2026 20:234,31347,874,29628,028,00011,221,00092,778,496
9Sep 17, 2026 20:235,09555,092,75128,023,00018,347,00092,729,344