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 09:47limanjun99limanjun99Score: 4,050Success
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 09:494,03559,597,96625,804,00010,917,00093,106,176
2Apr 21, 2026 09:494,03868,458,16026,818,0009,932,00092,823,552
3Apr 21, 2026 09:494,04061,595,85527,828,0008,944,00093,126,656
4Apr 21, 2026 09:494,04566,562,02726,863,0009,949,00092,872,704
5Apr 21, 2026 09:494,05063,522,37125,900,00010,958,00093,212,672
6Apr 21, 2026 09:494,05761,587,91228,939,0007,983,00092,893,184
7Apr 21, 2026 09:494,06660,344,64327,001,00010,000,00093,138,944
8Apr 21, 2026 09:494,07059,568,21628,028,0009,009,00092,913,664
9Apr 21, 2026 09:494,07653,565,94326,068,00011,028,00092,909,568