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 listNov 3, 2026 03:59Andrew EpsteinAndrew EpsteinScore: 2,753Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 04:052,72935,738,79616,344,0008,492,00092,778,496
2Nov 3, 2026 04:052,73735,826,98416,399,0008,513,00092,692,480
3Nov 3, 2026 04:052,74936,495,35916,470,0008,553,00092,815,360
4Nov 3, 2026 04:052,75236,311,34516,487,0008,559,00092,741,632
5Nov 3, 2026 04:052,75335,907,28916,438,0008,616,00092,811,264
6Nov 3, 2026 04:052,75736,442,45916,488,0008,602,00092,794,880
7Nov 3, 2026 04:052,75836,451,06716,497,0008,601,00092,774,400
8Nov 3, 2026 04:052,77236,604,33516,547,0008,684,00092,758,016
9Nov 3, 2026 04:052,77436,607,83016,577,0008,670,00092,651,520