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 25, 2026 09:16olliecrowolliecrowScore: 5,613Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 25, 2026 09:175,58270,955,99931,875,00018,926,00094,806,016
2Apr 25, 2026 09:175,59067,439,67833,917,00016,958,00094,793,728
3Apr 25, 2026 09:175,60170,661,40631,986,00018,992,00094,793,728
4Apr 25, 2026 09:175,61070,904,19233,034,00018,018,00094,801,920
5Apr 25, 2026 09:175,61368,448,08031,051,00020,033,00094,613,504
6Apr 25, 2026 09:175,62869,618,13032,139,00019,083,00094,801,920
7Apr 25, 2026 09:175,62970,883,12637,168,00014,063,00094,801,920
8Apr 25, 2026 09:175,63168,566,89229,143,00022,108,00094,789,632
9Apr 25, 2026 09:175,66267,690,86233,342,00018,186,00094,801,920