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:40Andrew EpsteinAndrew EpsteinScore: 3,444Success
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:463,42141,516,48422,698,0008,435,00092,745,728
2Sep 14, 2026 02:463,42841,604,20722,742,0008,455,00092,737,536
3Sep 14, 2026 02:463,42941,526,17022,594,0008,617,00092,749,824
4Sep 14, 2026 02:463,43442,332,75622,786,0008,469,00092,786,688
5Sep 14, 2026 02:463,44441,595,05022,633,0008,714,00092,737,536
6Sep 14, 2026 02:463,45041,727,01322,877,0008,523,00092,762,112
7Sep 14, 2026 02:463,45041,750,91822,729,0008,675,00092,725,248
8Sep 14, 2026 02:463,45941,764,13022,889,0008,590,00092,762,112
9Sep 14, 2026 02:463,46042,464,08622,908,0008,584,00092,749,824