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 listSep 15, 2026 15:38Victor MerckléVictor MerckléScore: 2,743Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 15:442,72733,610,41116,245,0008,576,00092,725,248stderr
2Sep 15, 2026 15:442,73333,539,49616,126,0008,749,00092,766,208stderr
3Sep 15, 2026 15:442,74134,318,68516,325,0008,622,00092,766,208stderr
4Sep 15, 2026 15:442,74133,623,35616,162,0008,782,00092,721,152stderr
5Sep 15, 2026 15:442,74334,354,15216,315,0008,652,00092,782,592stderr
6Sep 15, 2026 15:442,74333,714,30216,377,0008,585,00092,708,864stderr
7Sep 15, 2026 15:442,74833,701,26616,151,0008,858,00092,672,000stderr
8Sep 15, 2026 15:442,74833,878,27016,299,0008,715,00092,786,688stderr
9Sep 15, 2026 15:442,75134,403,92116,331,0008,709,00092,721,152stderr