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 listMay 18, 2026 05:36M-RochatM-RochatScore: 7,337Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 05:477,32075,844,67158,247,0008,368,00092,688,384
2May 18, 2026 05:477,32977,645,35458,212,0008,485,00092,753,920
3May 18, 2026 05:477,33375,874,53358,367,0008,369,00092,733,440
4May 18, 2026 05:477,33576,855,01158,383,0008,370,00092,708,864
5May 18, 2026 05:477,33777,181,55658,336,0008,439,00092,712,960
6May 18, 2026 05:477,33778,830,63958,486,0008,281,00092,700,672
7May 18, 2026 05:477,34277,731,81858,336,0008,480,00092,749,824
8May 18, 2026 05:477,34475,964,24058,383,0008,451,00092,807,168
9May 18, 2026 05:477,35776,101,32458,617,0008,338,00092,717,056