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 14, 2026 23:14Andrew EpsteinAndrew EpsteinScore: 3,267Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 23:323,23939,784,38421,023,0008,455,00092,737,536
2Sep 14, 2026 23:323,25540,044,48921,145,0008,483,00092,762,112
3Sep 14, 2026 23:323,25539,968,08621,146,0008,482,00092,762,112
4Sep 14, 2026 23:323,26440,053,46821,208,0008,501,00092,766,208
5Sep 14, 2026 23:323,26740,039,38921,185,0008,549,00092,737,536
6Sep 14, 2026 23:323,26840,117,55021,213,0008,528,00092,790,784
7Sep 14, 2026 23:323,27040,084,46821,178,0008,579,00092,692,480
8Sep 14, 2026 23:323,27340,120,43921,179,0008,612,00092,729,344
9Sep 14, 2026 23:323,28140,865,38721,309,0008,551,00092,766,208