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 21:40Andrew EpsteinAndrew EpsteinScore: 3,978Success
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 22:013,95446,945,18227,358,0008,624,00092,766,208
2Sep 14, 2026 22:013,95846,295,22227,430,0008,593,00092,737,536
3Sep 14, 2026 22:013,95946,381,52227,535,0008,500,00092,741,632
4Sep 14, 2026 22:013,96346,333,69227,600,0008,464,00092,794,880
5Sep 14, 2026 22:013,97847,293,33027,539,0008,662,00092,798,976
6Sep 14, 2026 22:014,00647,415,69727,731,0008,727,00092,786,688
7Sep 14, 2026 22:014,03347,739,45427,976,0008,729,00092,745,728
8Sep 14, 2026 22:014,08447,554,84828,666,0008,505,00092,729,344
9Sep 14, 2026 22:014,10747,784,18428,804,0008,571,00092,700,672