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 12, 2026 22:10Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 00:18Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 01:47022,699,0228,520,0003,471,00041,852,928invalid character 's' looking for beginning of value
2Sep 5, 2026 01:47020,648,8127,977,0004,249,00041,807,872invalid character '"' after object key:value pair
3Sep 5, 2026 01:47020,574,5868,572,0003,454,00041,820,160invalid character 's' looking for beginning of value
4Jun 12, 2026 22:162,66231,845,83615,574,0008,658,00092,745,728
5Jun 12, 2026 22:162,66331,904,02315,571,0008,667,00092,688,384
6Jun 12, 2026 22:162,66631,904,26715,594,0008,668,00092,770,304
7Jun 12, 2026 22:162,66731,786,00515,570,0008,708,00092,704,768
8Jun 12, 2026 22:162,67231,956,47215,591,0008,728,00092,708,864
9Jun 12, 2026 22:162,67931,883,84015,650,0008,736,00092,729,344
10Jun 12, 2026 22:162,68732,169,97815,666,0008,791,00092,708,864
11Jun 12, 2026 22:162,69032,034,62515,689,0008,793,00092,733,440
12Jun 12, 2026 22:162,69032,066,50715,688,0008,793,00092,717,056