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 listApr 20, 2026 16:25BenBenError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 01:43Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 01:500527,415,284446,823,00070,424,000139,776,000invalid character '.' looking for beginning of value
2Sep 18, 2026 01:500525,742,464446,643,00068,915,000139,747,328invalid character '.' looking for beginning of value
3Sep 18, 2026 01:500525,897,228447,061,00068,539,000140,046,336invalid character '.' looking for beginning of value
4Apr 20, 2026 16:2837,709370,595,280299,265,00043,892,00094,531,584
5Apr 20, 2026 16:2837,932362,698,293297,298,00047,887,00094,539,776
6Apr 20, 2026 16:2837,936372,715,932296,332,00048,889,00094,601,216