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 listAug 15, 2026 09:13Tomislav TunkovicTomislav TunkovicScore: 2,483Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 09:202,45630,700,38713,923,0008,429,00092,741,632
2Aug 15, 2026 09:202,47130,916,28114,097,0008,393,00092,692,480
3Aug 15, 2026 09:202,47831,535,95114,122,0008,431,00092,753,920
4Aug 15, 2026 09:202,48230,928,22114,139,0008,453,00092,741,632
5Aug 15, 2026 09:202,48330,981,85214,128,0008,475,00092,704,768
6Aug 15, 2026 09:202,48430,986,64314,136,0008,475,00092,721,152
7Aug 15, 2026 09:202,49231,044,89413,982,0008,697,00092,741,632
8Aug 15, 2026 09:202,49731,104,42614,182,0008,542,00092,766,208
9Aug 15, 2026 09:202,50131,096,84614,190,0008,572,00092,766,208