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 3, 2026 18:27TudyMTudyMScore: 8,378Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 18:338,34391,572,43258,334,00017,589,00094,642,176
2May 3, 2026 18:338,36292,326,36558,617,00017,480,00094,638,080
3May 3, 2026 18:338,37093,403,25758,512,00017,656,00094,625,792
4May 3, 2026 18:338,37192,210,92959,391,00016,790,00094,650,368
5May 3, 2026 18:338,37889,991,81558,804,00017,444,00094,646,272
6May 3, 2026 18:338,38693,013,75758,856,00017,465,00094,638,080
7May 3, 2026 18:338,38892,406,12159,516,00016,818,00094,633,984
8May 3, 2026 18:338,40993,405,41558,893,00017,636,00094,642,176
9May 3, 2026 18:338,43192,028,18959,282,00017,441,00094,605,312