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 15:14limanjun99limanjun99Score: 3,116Success
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 15:173,09550,306,60319,117,0009,055,00093,151,232
2Apr 21, 2026 15:173,09844,103,90319,133,0009,063,00092,999,680
3Apr 21, 2026 15:173,10944,896,14418,192,00010,106,00093,011,968
4Apr 21, 2026 15:173,11047,634,82419,205,0009,097,00092,925,952
5Apr 21, 2026 15:173,11643,347,49519,244,0009,115,00093,229,056
6Apr 21, 2026 15:173,12442,989,00818,279,00010,155,00093,122,560
7Apr 21, 2026 15:173,13049,980,34519,329,0009,155,00093,147,136
8Apr 21, 2026 15:173,13445,103,88319,354,0009,168,00093,003,776
9Apr 21, 2026 15:173,13751,466,09918,355,00010,197,00093,130,752