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 06:24M-RochatM-RochatScore: 5,418Success
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 06:425,40561,463,50640,918,0008,275,00092,782,592
2May 18, 2026 06:425,41661,376,20440,981,0008,307,00092,712,960
3May 18, 2026 06:425,41658,486,84240,991,0008,300,00092,758,016
4May 18, 2026 06:425,41758,404,29340,967,0008,336,00092,807,168
5May 18, 2026 06:425,41861,204,75640,907,0008,405,00092,721,152
6May 18, 2026 06:425,42558,525,57940,985,0008,385,00092,712,960
7May 18, 2026 06:425,42958,509,73041,090,0008,317,00092,766,208
8May 18, 2026 06:425,43458,607,50541,060,0008,390,00092,741,632
9May 18, 2026 06:425,43958,901,55141,221,0008,279,00092,745,728