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 listMar 17, 2026 09:58Dominique GarmierDominique GarmierScore: 7,764Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 09:587,72996,860,07453,252,00017,081,00094,543,872
2Mar 17, 2026 09:587,75597,921,61851,687,00018,885,00094,539,776
3Mar 17, 2026 09:587,758101,278,15552,698,00017,897,00094,564,352
4Mar 17, 2026 09:587,76499,990,91150,750,00019,901,00094,564,352
5Mar 17, 2026 09:587,76498,691,92753,496,00017,159,00094,564,352
6Mar 17, 2026 09:587,784104,314,82550,882,00019,953,00094,539,776
7Mar 17, 2026 09:587,785102,517,13251,888,00018,959,00094,564,352
8Mar 17, 2026 09:587,78594,665,60651,888,00018,959,00094,547,968
9Mar 17, 2026 09:587,81498,865,16453,081,00018,027,00094,564,352