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 18, 2026 02:51Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 19:50Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 20:03011,859,85902,014,0002,179,072invalid character '+' after object key:value pair
2Sep 4, 2026 20:03011,549,24202,014,0002,179,072invalid character '5' after object key:value pair
3Sep 4, 2026 20:03011,642,62102,035,0002,179,072invalid character '0' after object key:value pair
4Aug 18, 2026 03:134,04446,972,28918,869,00017,938,00094,453,760
5Aug 18, 2026 03:134,04646,506,43618,882,00017,938,00094,453,760
6Aug 18, 2026 03:134,05046,972,31618,894,00017,966,00094,408,704
7Aug 18, 2026 03:134,05446,682,20018,489,00018,410,00094,408,704
8Aug 18, 2026 03:134,05446,683,28718,868,00018,029,00094,453,760
9Aug 18, 2026 03:134,05646,950,33418,887,00018,026,00094,408,704
10Aug 18, 2026 03:134,06046,626,99618,931,00018,020,00094,408,704
11Aug 18, 2026 03:134,07348,239,67218,934,00018,133,00094,453,760
12Aug 18, 2026 03:134,10147,112,11118,644,00018,680,00094,408,704