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 listSep 14, 2026 22:25Andrew EpsteinAndrew EpsteinScore: 3,225Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 22:533,19739,493,95420,509,0008,585,00092,753,920
2Sep 14, 2026 22:533,20539,428,78920,721,0008,446,00092,770,304
3Sep 14, 2026 22:533,20639,493,17420,727,0008,448,00092,835,840
4Sep 14, 2026 22:533,20739,559,75020,714,0008,473,00092,729,344
5Sep 14, 2026 22:533,22540,362,23920,806,0008,544,00092,729,344
6Sep 14, 2026 22:533,23340,572,28720,880,0008,549,00092,696,576
7Sep 14, 2026 22:533,24140,507,20420,900,0008,601,00092,749,824
8Sep 14, 2026 22:533,24540,614,39020,892,0008,645,00092,733,440
9Sep 14, 2026 22:533,24840,517,01120,794,0008,769,00092,721,152