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:33limanjun99limanjun99Score: 3,644Success
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:353,62160,625,85421,968,00010,984,00092,844,032
2Apr 21, 2026 10:353,62760,466,00424,010,0009,003,00092,966,912
3Apr 21, 2026 10:353,63463,699,30324,051,0009,019,00093,102,080
4Apr 21, 2026 10:353,63565,291,55623,055,00010,024,00092,827,648
5Apr 21, 2026 10:353,64456,584,67124,122,0009,045,00092,909,568
6Apr 21, 2026 10:353,64453,598,80722,109,00011,054,00093,134,848
7Apr 21, 2026 10:353,64553,579,06623,124,00010,053,00092,844,032
8Apr 21, 2026 10:353,65556,574,85724,190,0009,071,00092,860,416
9Apr 21, 2026 10:353,65856,570,07626,229,0007,061,00092,905,472