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 11, 2026 02:44Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 19:06Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 19:13021,658,4898,418,0004,721,00041,836,544invalid character '0' after object key:value pair
2Sep 4, 2026 19:13021,425,3458,358,0004,618,00041,848,832invalid character 's' looking for beginning of value
3Sep 4, 2026 19:13021,542,1788,392,0004,591,00041,848,832invalid character 'o' looking for beginning of value
4Jun 11, 2026 02:502,84035,662,94716,963,0008,885,00092,745,728
5Jun 11, 2026 02:502,84435,484,22417,020,0008,869,00092,762,112
6Jun 11, 2026 02:502,84633,905,50516,952,0008,953,00092,749,824
7Jun 11, 2026 02:502,85635,783,81617,062,0008,935,00092,798,976
8Jun 11, 2026 02:502,85733,565,55817,057,0008,946,00092,807,168
9Jun 11, 2026 02:502,85835,589,09117,105,0008,906,00092,794,880
10Jun 11, 2026 02:502,87436,440,46117,268,0008,886,00092,745,728
11Jun 11, 2026 02:502,89333,830,19817,199,0009,129,00092,794,880
12Jun 11, 2026 02:502,90233,926,82917,228,0009,185,00092,774,400