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 14, 2026 17:06Josu San MartinJosu San MartinError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 14, 2026 17:220157,087,046125,633,00023,776,000138,432,512diff: map[string]any{ + "age": s"61", - "height": s"187.1", + "height": s"184", "id": s"559508", "married": bool(true), }
2May 14, 2026 17:220158,587,936125,143,00023,843,000138,432,512diff: map[string]any{ + "age": s"57", - "height": s"181.8", + "height": s"150.7", "id": s"140226", - "married": bool(true), + "married": bool(false), + "phones": []any{ + map[string]any{"code": string("+1"), "number": s"11738555...
3May 14, 2026 17:220156,319,401125,424,00023,775,000138,432,512diff: map[string]any{ + "age": s"54", - "height": s"198.6", + "height": s"168.7", "id": s"957636", "married": bool(true), "phones": []any{ - map[string]any{"code": string("+5"), "number": s"1778791636"}, + map[string]any{"c...