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 15:53Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 21:54Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 22:02051,009,37236,990,0005,581,00051,691,520invalid character 's' looking for beginning of valuestderr
2Sep 4, 2026 22:02050,625,43136,796,0005,424,00051,687,424invalid character '3' after object key:value pairstderr
3Sep 4, 2026 22:02051,310,05336,866,0005,314,00051,720,192invalid character 's' looking for beginning of valuestderr
4Aug 19, 2026 16:002,48531,226,91613,696,0008,919,00092,815,360stderr
5Aug 19, 2026 16:002,50031,234,77313,611,0009,142,00092,811,264stderr
6Aug 19, 2026 16:002,50431,408,19413,739,0009,052,00092,798,976stderr
7Aug 19, 2026 16:002,50631,072,03113,799,0009,014,00092,815,360stderr
8Aug 19, 2026 16:002,50831,215,68113,914,0008,915,00092,819,456stderr
9Aug 19, 2026 16:002,53232,997,06714,190,0008,852,00092,835,840stderr
10Aug 19, 2026 16:002,53531,563,88514,221,0008,853,00092,823,552stderr
11Aug 19, 2026 16:002,53832,424,63014,047,0009,051,00092,737,536stderr
12Aug 19, 2026 16:002,54431,594,86614,217,0008,942,00092,803,072stderr