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 27, 2026 20:22Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 05:10Tomislav Tunkovic15.98CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 05:420655,007,050625,456,00019,392,000100,687,872diff: map[string]any{ - "height": s"177.3", + "height": s"177.300000000000000000000000001", "id": s"880890", "married": bool(true), "phones": []any{map[string]any{"code": string("+9"), "number": s"1581578975"}, map[string]any{"code...stderr
2Sep 5, 2026 05:420651,998,155622,030,00019,177,000100,687,872invalid character '0' after object key:value pairstderr
3Sep 5, 2026 05:420642,157,301612,360,00018,416,000100,687,872diff: map[string]any{ + "age": s"0", "height": s"188.5", "id": s"670015", ... // 2 identical entries } stderr
4Apr 27, 2026 20:2262,486587,410,761549,641,00018,987,00094,650,368stderr
5Apr 27, 2026 20:2262,566587,450,387548,375,00020,976,00094,838,784stderr
6Apr 27, 2026 20:2262,581588,194,991550,507,00018,983,00094,842,880stderr