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 17:08Victor MerckléVictor MerckléScore: 2,745Success
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 17:142,72833,847,94115,904,0008,922,00092,725,248
2Jun 11, 2026 17:142,73733,964,52716,146,0008,767,00092,733,440
3Jun 11, 2026 17:142,74234,057,84516,185,0008,775,00092,733,440
4Jun 11, 2026 17:142,74435,876,70416,161,0008,812,00092,725,248
5Jun 11, 2026 17:142,74534,037,57816,182,0008,801,00092,708,864
6Jun 11, 2026 17:142,75934,097,48316,219,0008,889,00092,696,576
7Jun 11, 2026 17:142,76734,227,81416,336,0008,852,00092,762,112
8Jun 11, 2026 17:142,76834,237,98616,287,0008,909,00092,774,400
9Jun 11, 2026 17:142,77135,627,69016,292,0008,925,00092,782,592