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 02:19Andrew EpsteinAndrew EpsteinScore: 3,692Success
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 02:283,67343,819,03624,864,0008,562,00092,741,632
2Sep 14, 2026 02:283,67343,754,82024,865,0008,562,00092,704,768
3Sep 14, 2026 02:283,67743,842,71024,866,0008,602,00092,819,456
4Sep 14, 2026 02:283,68143,776,37224,914,0008,585,00092,794,880
5Sep 14, 2026 02:283,69244,664,49624,950,0008,649,00092,782,592
6Sep 14, 2026 02:283,69543,896,31524,952,0008,677,00092,733,440
7Sep 14, 2026 02:283,69944,001,42024,999,0008,669,00092,745,728
8Sep 14, 2026 02:283,71744,800,53025,077,0008,751,00092,729,344
9Sep 14, 2026 02:283,71744,835,81825,066,0008,763,00092,753,920