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 9, 2026 23:51Victor MerckléVictor MerckléScore: 2,744Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 9, 2026 23:562,71833,699,29216,062,0008,678,00092,745,728
2Jun 9, 2026 23:562,72733,857,59016,077,0008,739,00092,672,000
3Jun 9, 2026 23:562,73933,952,12116,156,0008,775,00092,782,592
4Jun 9, 2026 23:562,74133,904,29116,165,0008,779,00092,741,632
5Jun 9, 2026 23:562,74433,934,45316,154,0008,825,00092,725,248
6Jun 9, 2026 23:562,75034,020,31316,152,0008,876,00092,766,208
7Jun 9, 2026 23:562,75434,070,49216,199,0008,870,00092,803,072
8Jun 9, 2026 23:562,75534,012,74516,259,0008,813,00092,745,728
9Jun 9, 2026 23:562,75734,116,51516,202,0008,895,00092,770,304