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 21, 2026 10:27limanjun99limanjun99Score: 3,769Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 10:293,75954,848,60925,155,0009,056,00092,962,816
2Apr 21, 2026 10:293,75956,583,94524,151,00010,062,00093,196,288
3Apr 21, 2026 10:293,76362,501,41626,192,0008,059,00092,835,840
4Apr 21, 2026 10:293,76654,625,95124,193,00010,080,00093,147,136
5Apr 21, 2026 10:293,76957,649,55024,215,00010,089,00092,880,896
6Apr 21, 2026 10:293,77159,581,13724,229,00010,095,00093,179,904
7Apr 21, 2026 10:293,77656,526,65127,291,0007,075,00093,159,424
8Apr 21, 2026 10:293,78556,475,98024,318,00010,132,00092,876,800
9Apr 21, 2026 10:293,78767,581,74726,359,0008,110,00092,893,184