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 12, 2026 22:29Victor MerckléVictor MerckléScore: 2,674Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 12, 2026 22:352,66231,911,23915,559,0008,670,00092,774,400
2Jun 12, 2026 22:352,66831,866,79215,598,0008,684,00092,762,112
3Jun 12, 2026 22:352,67131,791,67515,614,0008,697,00092,807,168
4Jun 12, 2026 22:352,67131,934,36415,590,0008,725,00092,774,400
5Jun 12, 2026 22:352,67432,016,31515,636,0008,700,00092,708,864
6Jun 12, 2026 22:352,67731,967,22815,594,0008,772,00092,766,208
7Jun 12, 2026 22:352,68432,098,08215,631,0008,800,00092,774,400
8Jun 12, 2026 22:352,69331,957,74515,705,0008,807,00092,737,536
9Jun 12, 2026 22:352,70732,248,07315,761,0008,874,00092,749,824