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:51Victor MerckléVictor MerckléScore: 2,915Success
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 02:002,90735,415,87017,487,0008,968,00092,774,400
2Jun 11, 2026 02:002,90935,467,21417,458,0009,018,00092,749,824
3Jun 11, 2026 02:002,91536,809,77317,499,0009,029,00092,782,592
4Jun 11, 2026 02:002,91535,562,94817,527,0009,004,00092,696,576
5Jun 11, 2026 02:002,91536,775,35317,491,0009,037,00092,712,960
6Jun 11, 2026 02:002,92035,633,79917,543,0009,035,00092,770,304
7Jun 11, 2026 02:002,93435,638,90617,575,0009,125,00092,868,608
8Jun 11, 2026 02:002,93435,647,02317,566,0009,134,00092,753,920
9Jun 11, 2026 02:002,93835,745,95417,586,0009,156,00092,737,536