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 listJun 11, 2026 01:30Victor MerckléVictor MerckléScore: 2,864Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 01:382,83835,058,41416,917,0008,915,00092,815,360
2Jun 11, 2026 01:382,85434,923,62017,224,0008,756,00092,745,728
3Jun 11, 2026 01:382,85534,966,40017,058,0008,923,00092,823,552
4Jun 11, 2026 01:382,86235,069,41017,083,0008,970,00092,786,688
5Jun 11, 2026 01:382,86435,888,39117,075,0008,989,00092,839,936
6Jun 11, 2026 01:382,86535,241,75617,072,0009,006,00092,749,824
7Jun 11, 2026 01:382,87235,076,05317,122,0009,014,00092,733,440
8Jun 11, 2026 01:382,88236,779,94117,157,0009,078,00092,745,728
9Jun 11, 2026 01:382,88335,174,69417,177,0009,059,00092,815,360