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 listAug 19, 2026 21:12Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 18:07Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 18:16051,230,62038,420,0004,376,00051,687,424invalid character 'a' looking for beginning of valuestderr
2Sep 4, 2026 18:16051,263,65038,466,0004,432,00051,687,424invalid character 's' looking for beginning of valuestderr
3Sep 4, 2026 18:16051,323,37338,467,0004,430,00051,699,712invalid character 's' looking for beginning of valuestderr
4Aug 19, 2026 21:242,35929,790,47612,746,0008,726,00092,741,632stderr
5Aug 19, 2026 21:242,36329,838,73612,730,0008,778,00092,737,536stderr
6Aug 19, 2026 21:242,36329,866,89112,679,0008,825,00092,737,536stderr
7Aug 19, 2026 21:242,36529,919,57912,703,0008,819,00092,749,824stderr
8Aug 19, 2026 21:242,37129,918,01312,695,0008,887,00092,749,824stderr
9Aug 19, 2026 21:242,37329,985,02412,685,0008,915,00092,782,592stderr
10Aug 19, 2026 21:242,37329,989,02113,028,0008,567,00092,684,288stderr
11Aug 19, 2026 21:242,37829,986,74013,132,0008,512,00092,712,960stderr
12Aug 19, 2026 21:242,39530,160,04612,838,0008,964,00092,725,248stderr