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 09:38Andrew EpsteinAndrew EpsteinScore: 2,428Success
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 09:582,40131,186,65813,474,0008,376,00092,737,536
2Nov 3, 2026 09:582,40331,474,19013,518,0008,352,00092,741,632
3Nov 3, 2026 09:582,40531,186,44313,363,0008,527,00092,733,440
4Nov 3, 2026 09:582,40931,143,62813,548,0008,375,00092,749,824
5Nov 3, 2026 09:582,42831,392,24113,461,0008,637,00092,696,576
6Nov 3, 2026 09:582,42931,710,85913,592,0008,517,00092,762,112
7Nov 3, 2026 09:582,43731,945,64713,615,0008,568,00092,741,632
8Nov 3, 2026 09:582,45831,660,25913,716,0008,652,00092,762,112
9Nov 3, 2026 09:582,46532,223,90813,774,0008,659,00092,737,536