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 listApr 28, 2026 10:11TudyMTudyMError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 01:30Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 01:410277,431,182233,813,00031,959,000115,396,608invalid character ',' looking for beginning of value
2Sep 18, 2026 01:410275,679,220233,703,00031,482,000115,683,328invalid character ',' looking for beginning of value
3Sep 18, 2026 01:410276,349,890234,220,00031,200,000115,785,728invalid character ',' looking for beginning of value
4Apr 28, 2026 10:1514,610151,010,496107,961,00024,990,00094,769,152
5Apr 28, 2026 10:1514,657151,548,032108,495,00024,884,00094,584,832
6Apr 28, 2026 10:1514,660151,396,526110,508,00022,898,00094,597,120
7Apr 28, 2026 10:1514,660153,600,356109,516,00023,894,00094,638,080
8Apr 28, 2026 10:1514,664153,691,110110,539,00022,904,00094,633,984
9Apr 28, 2026 10:1514,666150,226,964110,558,00022,908,00094,638,080
10Apr 28, 2026 10:1514,688150,091,238110,725,00022,943,00094,629,888
11Apr 28, 2026 10:1514,730154,498,177111,042,00023,008,00094,625,792
12Apr 28, 2026 10:1514,934152,460,942109,926,00025,982,00094,629,888