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 13:30Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 01:16Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 02:53049,597,01336,595,0004,426,00051,683,328invalid character 's' looking for beginning of valuestderr
2Sep 5, 2026 02:53049,534,70936,704,0004,429,00051,666,944invalid character '+' looking for beginning of valuestderr
3Sep 5, 2026 02:53049,677,80736,755,0004,497,00051,666,944invalid character 'r' looking for beginning of valuestderr
4Aug 19, 2026 13:362,42130,450,00013,580,0008,460,00092,712,960stderr
5Aug 19, 2026 13:362,42530,588,78313,515,0008,556,00092,753,920stderr
6Aug 19, 2026 13:362,43230,484,42813,667,0008,470,00092,753,920stderr
7Aug 19, 2026 13:362,43330,552,78713,629,0008,514,00092,745,728stderr
8Aug 19, 2026 13:362,43531,275,82813,646,0008,517,00092,774,400stderr
9Aug 19, 2026 13:362,44530,549,27613,694,0008,560,00092,737,536stderr
10Aug 19, 2026 13:362,44931,271,57113,721,0008,572,00092,745,728stderr
11Aug 19, 2026 13:362,45730,737,35313,706,0008,653,00092,725,248stderr
12Aug 19, 2026 13:362,45931,323,89513,732,0008,646,00092,708,864stderr