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 listApr 24, 2026 06:25olliecrowolliecrowScore: 4,802Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 24, 2026 06:274,74261,228,56828,105,00015,056,00094,797,824
2Apr 24, 2026 06:274,74766,052,10325,117,00018,084,00094,810,112
3Apr 24, 2026 06:274,78762,104,96324,315,00019,249,00094,806,016
4Apr 24, 2026 06:274,79659,935,82121,822,00021,822,00094,789,632
5Apr 24, 2026 06:274,80263,440,12823,837,00019,864,00094,797,824
6Apr 24, 2026 06:274,80664,661,56324,851,00018,887,00094,613,504
7Apr 24, 2026 06:274,80762,945,89123,865,00019,887,00094,793,728
8Apr 24, 2026 06:274,81263,987,49124,883,00018,911,00094,806,016
9Apr 24, 2026 06:274,81463,032,58524,891,00018,917,00094,621,696