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 listJun 5, 2026 17:16Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 31, 2026 14:50Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 31, 2026 15:23022,376,1817,048,0004,582,00039,469,056invalid character ',' looking for beginning of value
2Oct 31, 2026 15:23022,237,8577,783,0003,775,00039,477,248invalid character ',' looking for beginning of value
3Oct 31, 2026 15:23022,261,7837,800,0003,832,00039,464,960invalid character ',' looking for beginning of value
4Jun 5, 2026 17:212,74034,065,90016,358,0008,582,00092,762,112
5Jun 5, 2026 17:212,74134,088,53416,090,0008,861,00092,745,728
6Jun 5, 2026 17:212,74434,284,09416,106,0008,868,00092,766,208
7Jun 5, 2026 17:212,74534,079,18416,278,0008,710,00092,774,400
8Jun 5, 2026 17:212,75934,130,65416,346,0008,765,00092,770,304
9Jun 5, 2026 17:212,76234,208,23216,325,0008,814,00092,745,728
10Jun 5, 2026 17:212,76334,218,34916,361,0008,787,00092,790,784
11Jun 5, 2026 17:212,76834,261,05116,380,0008,816,00092,717,056
12Jun 5, 2026 17:212,77434,315,56316,375,0008,876,00092,708,864