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 01:30Andrew EpsteinAndrew EpsteinScore: 3,525Success
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 01:413,50242,759,40323,326,0008,544,00092,684,288
2Nov 3, 2026 01:413,50742,835,38923,346,0008,576,00092,708,864
3Nov 3, 2026 01:413,51343,157,22423,384,0008,586,00092,741,632
4Nov 3, 2026 01:413,51543,494,85723,397,0008,593,00092,729,344
5Nov 3, 2026 01:413,52542,936,79923,408,0008,672,00092,688,384
6Nov 3, 2026 01:413,52643,461,43823,463,0008,626,00092,745,728
7Nov 3, 2026 01:413,52742,915,19723,434,0008,665,00092,712,960
8Nov 3, 2026 01:413,52943,081,35123,454,0008,665,00092,737,536
9Nov 3, 2026 01:413,55743,774,34523,599,0008,770,00092,696,576