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 16:35TudyMTudyMScore: 8,660Success
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 16:458,59094,011,68761,880,00016,293,00094,638,080
2May 3, 2026 16:458,63792,987,77962,091,00016,508,00094,642,176
3May 3, 2026 16:458,64192,443,27662,055,00016,586,00094,633,984
4May 3, 2026 16:458,65594,665,13761,481,00017,281,00094,625,792
5May 3, 2026 16:458,66094,883,06862,160,00016,647,00094,629,888
6May 3, 2026 16:458,66894,888,60161,536,00017,345,00094,633,984
7May 3, 2026 16:458,67093,782,41262,218,00016,682,00094,633,984
8May 3, 2026 16:458,67194,624,18761,546,00017,369,00094,633,984
9May 3, 2026 16:458,67494,306,03361,611,00017,327,00094,642,176