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 19:03Charles CabergsCharles CabergsScore: 4,184Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 19:054,14961,359,41617,887,00019,875,00094,797,824
2Apr 28, 2026 19:054,17757,721,91217,005,00021,006,00094,793,728
3Apr 28, 2026 19:054,18255,149,29822,036,00016,026,00094,793,728
4Apr 28, 2026 19:054,18355,347,29121,040,00017,033,00094,801,920
5Apr 28, 2026 19:054,18466,511,87422,047,00016,034,00094,613,504
6Apr 28, 2026 19:054,19157,932,41321,079,00017,064,00094,789,632
7Apr 28, 2026 19:054,21057,912,61517,141,00021,174,00094,797,824
8Apr 28, 2026 19:054,23755,512,98418,266,00020,296,00094,801,920
9Apr 28, 2026 19:054,25258,350,81820,835,00017,859,00094,793,728