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:07M-RochatM-RochatScore: 5,668Success
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:215,65961,084,60443,243,0008,259,00092,758,016
2May 18, 2026 06:215,66161,507,76143,228,0008,296,00092,725,248
3May 18, 2026 06:215,66262,081,48843,223,0008,305,00092,774,400
4May 18, 2026 06:215,66463,673,58843,208,0008,336,00092,758,016
5May 18, 2026 06:215,66860,654,04743,308,0008,272,00092,749,824
6May 18, 2026 06:215,67760,970,04643,246,0008,423,00092,766,208
7May 18, 2026 06:215,68061,136,69943,228,0008,469,00092,753,920
8May 18, 2026 06:215,68160,790,52843,316,0008,390,00092,737,536
9May 18, 2026 06:215,68460,843,91343,354,0008,373,00092,786,688