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 listDec 24, 2025 01:21Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 17, 2026 21:25Andrew Epstein15.76CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 21:360297,737,687245,352,00041,914,000137,535,488invalid character '.' looking for beginning of value
2Sep 17, 2026 21:360297,256,853244,593,00040,822,000137,461,760invalid character '.' looking for beginning of value
3Sep 17, 2026 21:360293,505,959245,603,00036,773,000137,580,544invalid character '.' looking for beginning of value
4Dec 24, 2025 01:2120,647209,939,752167,900,00019,988,00094,625,792
5Dec 24, 2025 01:2120,661215,788,448163,017,00025,002,00094,789,632
6Dec 24, 2025 01:2120,696218,892,339164,418,00023,915,00094,773,248
7Dec 24, 2025 01:2120,725228,365,903166,645,00021,953,00094,797,824
8Dec 24, 2025 01:2120,839215,666,099167,681,00021,958,00094,789,632
9Dec 24, 2025 01:2120,900214,879,663163,161,00027,026,00094,576,640
10Dec 24, 2025 01:2120,952222,319,784163,709,00026,952,00094,785,536
11Dec 24, 2025 01:2121,834227,543,189164,745,00033,947,00094,789,632
12Dec 24, 2025 01:2122,476231,966,405168,618,00035,918,00094,801,920