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 8, 2026 11:39olliecrowolliecrowScore: 8,750Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 8, 2026 11:378,718107,059,03862,260,00017,071,00094,552,064
2Apr 8, 2026 11:398,728105,493,31463,538,00015,884,00094,674,944
3Apr 8, 2026 11:358,734102,865,77362,590,00016,889,00094,552,064
4Apr 8, 2026 11:378,736107,335,61265,587,00013,912,00094,683,136
5Apr 8, 2026 11:438,736110,740,45563,401,00016,101,00094,552,064
6Apr 8, 2026 11:438,738107,891,26460,630,00018,884,00094,552,064
7Apr 8, 2026 11:358,750105,986,85763,698,00015,924,00094,687,232
8Apr 8, 2026 11:398,75199,920,16062,711,00016,922,00094,683,136
9Apr 8, 2026 11:438,752110,524,40660,726,00018,914,00094,674,944
10Apr 8, 2026 11:378,777104,011,26463,898,00015,974,00094,547,968
11Apr 8, 2026 11:398,779106,196,71662,911,00016,976,00094,552,064
12Apr 8, 2026 11:358,832105,531,62963,292,00017,078,00094,552,064