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 3, 2026 04:19Andrew EpsteinAndrew EpsteinScore: 2,607Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 04:302,58434,388,75214,707,0008,808,00092,803,072
2Nov 3, 2026 04:302,59334,997,04314,799,0008,798,00092,729,344
3Nov 3, 2026 04:302,60234,968,14014,861,0008,821,00092,807,168
4Nov 3, 2026 04:302,60335,042,60714,875,0008,813,00092,798,976
5Nov 3, 2026 04:302,60735,086,21514,886,0008,841,00092,721,152
6Nov 3, 2026 04:302,61335,131,35414,922,0008,860,00092,692,480
7Nov 3, 2026 04:302,61635,172,69114,870,0008,943,00092,708,864
8Nov 3, 2026 04:302,62535,271,70314,926,0008,970,00092,782,592
9Nov 3, 2026 04:302,63035,260,51115,015,0008,922,00092,758,016