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 02:53Charles CabergsCharles CabergsScore: 4,246Success
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 02:554,20556,940,08020,143,00018,129,00094,609,408
2Apr 28, 2026 02:554,20655,974,12921,153,00017,124,00094,609,408
3Apr 28, 2026 02:554,23457,193,49419,763,00018,775,00094,801,920
4Apr 28, 2026 02:554,24255,025,71019,798,00018,808,00094,797,824
5Apr 28, 2026 02:554,24658,555,13718,824,00019,815,00094,609,408
6Apr 28, 2026 02:554,24857,476,58120,816,00017,842,00094,801,920
7Apr 28, 2026 02:554,25055,683,61617,854,00020,830,00094,801,920
8Apr 28, 2026 02:554,27162,190,56121,926,00016,942,00094,797,824
9Apr 28, 2026 02:554,27559,006,87120,952,00017,959,00094,785,536