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 18, 2026 02:47Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 10, 2026 08:44Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 10, 2026 08:47010,030,69901,656,0002,195,456invalid character '0' after object key:value pair
2Sep 10, 2026 08:4709,988,96601,521,0002,195,456invalid character '+' after object key:value pair
3Sep 10, 2026 08:47010,018,58101,677,0002,158,592invalid character '<' after object key:value pair
4Aug 18, 2026 03:043,99944,898,56018,835,00017,563,00094,416,896
5Aug 18, 2026 03:044,01244,886,27218,753,00017,764,00094,416,896
6Aug 18, 2026 03:044,03145,928,86719,031,00017,656,00094,416,896
7Aug 18, 2026 03:044,04845,312,64118,946,00017,897,00094,416,896
8Aug 18, 2026 03:044,05145,341,96819,068,00017,805,00094,416,896
9Aug 18, 2026 03:044,05345,302,33118,980,00017,906,00094,416,896
10Aug 18, 2026 03:044,05845,567,86319,113,00017,815,00094,416,896
11Aug 18, 2026 03:044,07645,520,89919,257,00017,835,00094,416,896
12Aug 18, 2026 03:044,08445,558,45419,209,00017,961,00094,416,896