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 14:59limanjun99limanjun99Score: 3,125Success
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:013,11752,724,40218,237,00010,131,00093,110,272
2Apr 21, 2026 15:013,11948,117,56919,264,0009,125,00093,204,480
3Apr 21, 2026 15:013,12048,713,04818,254,00010,141,00093,196,288
4Apr 21, 2026 15:013,12347,827,71219,285,0009,135,00093,147,136
5Apr 21, 2026 15:013,12544,298,40219,298,0009,141,00093,114,368
6Apr 21, 2026 15:013,12848,306,16519,320,0009,151,00093,081,600
7Apr 21, 2026 15:013,14046,345,80519,392,0009,185,00092,950,528
8Apr 21, 2026 15:013,14146,454,11619,399,0009,189,00092,925,952
9Apr 21, 2026 15:013,14246,135,08921,448,0007,149,00093,130,752