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 listNov 5, 2026 04:53Andrew EpsteinAndrew EpsteinScore: 2,435Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 05:302,40831,538,49213,393,0008,528,00092,708,864
2Nov 5, 2026 05:302,41831,120,14213,590,0008,416,00092,733,440
3Nov 5, 2026 05:302,43231,276,45913,595,0008,545,00092,708,864
4Nov 5, 2026 05:302,43431,312,24713,642,0008,516,00092,758,016
5Nov 5, 2026 05:302,43531,297,13113,565,0008,600,00092,749,824
6Nov 5, 2026 05:302,45431,456,61713,810,0008,530,00092,749,824
7Nov 5, 2026 05:302,52841,142,27414,285,0008,726,00092,770,304
8Nov 5, 2026 05:302,53239,959,77414,370,0008,673,00092,782,592
9Nov 5, 2026 05:302,64042,588,54314,594,0009,437,00092,704,768