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 5, 2026 16:15Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 21:58Tomislav Tunkovic10.01CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 22:16022,230,5397,918,0004,330,00041,832,448invalid character 'h' after object key:value pair
2Sep 4, 2026 22:16022,215,5457,960,0004,339,00041,840,640invalid character 's' looking for beginning of value
3Sep 4, 2026 22:16022,313,9518,046,0004,352,00041,803,776invalid character 's' looking for beginning of value
4Jun 5, 2026 16:202,91835,626,67717,912,0008,646,00092,741,632
5Jun 5, 2026 16:202,92535,648,58817,961,0008,664,00092,770,304
6Jun 5, 2026 16:202,92935,729,75517,969,0008,693,00092,729,344
7Jun 5, 2026 16:202,93735,714,37218,175,0008,558,00092,733,440
8Jun 5, 2026 16:202,93835,734,52418,192,0008,548,00092,766,208
9Jun 5, 2026 16:202,94235,844,41718,026,0008,755,00092,700,672
10Jun 5, 2026 16:202,94835,807,69318,181,0008,650,00092,798,976
11Jun 5, 2026 16:202,94935,930,45918,225,0008,612,00092,733,440
12Jun 5, 2026 16:202,95635,979,25718,228,0008,674,00092,733,440