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 listSep 8, 2026 22:54Andrew EpsteinAndrew EpsteinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:04Tomislav Tunkovic101.82CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:10012,068,6611,400,000020,480Exit with code 1:
2Sep 8, 2026 23:007,19376,329,73148,413,00017,050,00094,392,320
3Sep 8, 2026 23:007,20075,688,73149,560,00015,967,00094,392,320
4Sep 8, 2026 23:007,28576,417,10949,314,00016,980,00094,392,320
5Sep 8, 2026 23:007,29078,656,95649,471,00016,876,00094,392,320
6Sep 8, 2026 23:007,29877,043,81349,494,00016,921,00094,392,320
7Sep 8, 2026 23:007,30277,834,04149,460,00016,995,00094,392,320
8Sep 8, 2026 23:007,30576,535,72150,218,00016,259,00094,392,320
9Sep 8, 2026 23:007,36777,866,98350,092,00016,955,00094,392,320
10Sep 8, 2026 23:007,38077,258,78050,219,00016,939,00094,392,320