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:49Andrew EpsteinAndrew EpsteinScore: 3,338Success
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:543,31940,601,70921,757,0008,446,00092,741,632
2Sep 14, 2026 02:543,32040,540,18521,794,0008,420,00092,745,728
3Sep 14, 2026 02:543,32340,522,68421,816,0008,427,00092,737,536
4Sep 14, 2026 02:543,33740,755,41221,828,0008,542,00092,794,880
5Sep 14, 2026 02:543,33840,676,55321,713,0008,664,00092,753,920
6Sep 14, 2026 02:543,34240,765,25921,953,0008,461,00092,692,480
7Sep 14, 2026 02:543,34440,747,24421,898,0008,535,00092,688,384
8Sep 14, 2026 02:543,34441,468,12421,793,0008,639,00092,741,632
9Sep 14, 2026 02:543,35640,954,88621,796,0008,749,00092,774,400