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 26, 2026 20:40Charles CabergsCharles CabergsScore: 4,322Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 26, 2026 20:434,30054,014,63722,077,00017,060,00094,793,728
2Apr 26, 2026 20:434,30058,746,30415,052,00024,083,00094,797,824
3Apr 26, 2026 20:434,31259,077,94622,137,00017,106,00094,793,728
4Apr 26, 2026 20:434,32262,374,31717,146,00022,189,00094,793,728
5Apr 26, 2026 20:434,32259,573,19021,636,00017,702,00094,785,536
6Apr 26, 2026 20:434,33158,668,82516,751,00022,663,00094,793,728
7Apr 26, 2026 20:434,34357,075,59526,683,00012,847,00094,789,632
8Apr 26, 2026 20:434,34759,498,28122,747,00016,813,00094,793,728
9Apr 26, 2026 20:434,39457,570,14520,993,00018,994,00094,609,408