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 listMay 1, 2026 06:28olliecrowolliecrowScore: 6,504Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2026 06:306,48575,045,81642,014,00017,005,00094,797,824
2May 1, 2026 06:306,48873,256,53840,033,00019,016,00094,617,600
3May 1, 2026 06:306,49779,017,83844,097,00015,033,00094,797,824
4May 1, 2026 06:306,49778,677,97943,834,00015,291,00094,810,112
5May 1, 2026 06:306,50479,428,51744,141,00015,048,00094,789,632
6May 1, 2026 06:306,52174,425,13044,259,00015,088,00094,801,920
7May 1, 2026 06:306,53482,384,72046,365,00013,103,00094,797,824
8May 1, 2026 06:306,54783,872,36444,685,00014,895,00094,801,920
9May 1, 2026 06:306,56579,717,03543,814,00015,932,00094,801,920