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 19, 2025 20:53Aniruddha DebAniruddha DebScore: 2,958Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2025 20:532,94752,130,40715,892,00010,926,00094,576,640
2Aug 19, 2025 20:532,94847,240,98818,880,0007,949,00094,584,832
3Aug 19, 2025 20:532,95753,030,91219,931,0006,975,00094,609,408
4Aug 19, 2025 20:532,95849,741,62517,945,0008,972,00094,609,408
5Aug 19, 2025 20:532,95851,847,99217,948,0008,974,00094,523,392
6Aug 19, 2025 20:532,96250,628,60519,968,0006,988,00094,580,736
7Aug 19, 2025 20:532,96551,642,75317,989,0008,994,00094,658,560
8Aug 19, 2025 20:532,96645,619,22619,991,0006,997,00094,638,080
9Aug 19, 2025 20:532,98249,295,46020,100,0007,035,00094,650,368