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 listMay 3, 2026 13:50TudyMTudyMScore: 11,862Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 14:0111,843124,959,14590,439,00017,337,00094,638,080
2May 3, 2026 14:0111,849125,662,57690,522,00017,309,00094,625,792
3May 3, 2026 14:0111,852126,381,78590,561,00017,301,00094,633,984
4May 3, 2026 14:0111,853124,786,71090,484,00017,386,00094,625,792
5May 3, 2026 14:0111,862126,085,49390,580,00017,368,00094,621,696
6May 3, 2026 14:0111,864123,166,85090,467,00017,496,00094,638,080
7May 3, 2026 14:0111,884125,321,07490,546,00017,602,00094,633,984
8May 3, 2026 14:0111,888124,854,75790,286,00017,895,00094,633,984
9May 3, 2026 14:0111,901122,597,71890,035,00018,273,00094,597,120