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 17:06TudyMTudyMScore: 8,574Success
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 17:118,55093,523,66861,202,00016,604,00094,646,272
2May 3, 2026 17:118,55292,908,27560,477,00017,348,00094,638,080
3May 3, 2026 17:118,55393,586,85160,480,00017,357,00094,633,984
4May 3, 2026 17:118,56693,373,94061,299,00016,655,00094,638,080
5May 3, 2026 17:118,57495,501,51861,255,00016,772,00094,633,984
6May 3, 2026 17:118,57691,735,76560,619,00017,427,00094,642,176
7May 3, 2026 17:118,57793,992,39461,413,00016,643,00094,629,888
8May 3, 2026 17:118,58097,686,35460,455,00017,631,00094,646,272
9May 3, 2026 17:118,64494,027,73261,408,00017,255,00094,629,888