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 8, 2026 21:05Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 19:32Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 19:41020,840,9978,609,0003,690,00041,803,776invalid character '+' looking for beginning of value
2Sep 4, 2026 19:41020,808,5208,682,0003,711,00041,791,488invalid character 's' looking for beginning of value
3Sep 4, 2026 19:41024,742,9888,781,0003,419,00041,824,256invalid character 's' looking for beginning of value
4Jun 8, 2026 21:112,75632,857,65916,559,0008,523,00092,794,880
5Jun 8, 2026 21:112,76432,876,01816,587,0008,570,00092,745,728
6Jun 8, 2026 21:112,76833,046,29616,648,0008,546,00092,721,152
7Jun 8, 2026 21:112,77232,981,97516,664,0008,565,00092,696,576
8Jun 8, 2026 21:112,78133,093,03116,706,0008,608,00092,704,768
9Jun 8, 2026 21:112,78333,125,28916,699,0008,634,00092,704,768
10Jun 8, 2026 21:112,78733,054,28316,696,0008,671,00092,733,440
11Jun 8, 2026 21:112,79033,159,30016,730,0008,660,00092,762,112
12Jun 8, 2026 21:112,80033,228,24716,784,0008,702,00092,721,152