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:40limanjun99limanjun99Score: 3,153Success
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:423,12851,642,29820,335,0008,134,00093,134,848
2Apr 21, 2026 10:423,13957,568,71118,366,00010,203,00092,860,416
3Apr 21, 2026 10:423,15054,549,75922,736,0005,931,00092,868,608
4Apr 21, 2026 10:423,15157,554,61519,776,0008,899,00092,884,992
5Apr 21, 2026 10:423,15353,636,75017,811,00010,885,00092,839,936
6Apr 21, 2026 10:423,15355,372,02818,801,0009,895,00092,913,664
7Apr 21, 2026 10:423,16056,568,23917,852,00010,909,00092,897,280
8Apr 21, 2026 10:423,16060,368,53017,852,00010,909,00092,884,992
9Apr 21, 2026 10:423,16257,519,93517,864,00010,917,00093,134,848