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 28, 2026 19:55Shikhar SoniShikhar SoniError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 05:16Tomislav Tunkovic76.08CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 05:480146,848,334112,769,00023,938,000100,683,776diff: map[string]any{ - "height": s"0", "id": s"193023", - "married": bool(false), }
2Sep 5, 2026 05:480146,504,937112,674,00023,864,000100,683,776diff: map[string]any{ "age": s"27", - "height": s"170", + "height": s"0.0000001700E9", "id": s"325908", "married": bool(true), }
3Sep 5, 2026 05:480146,440,399112,894,00023,627,000100,683,776invalid character '0' after object key:value pair
4Jun 28, 2026 19:5712,931126,985,01395,532,00022,149,00094,392,320
5Jun 28, 2026 19:5713,145128,974,56097,637,00021,991,00094,392,320
6Jun 28, 2026 19:5713,177129,300,14095,789,00024,124,00094,392,320