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 5, 2026 06:21Victor MerckléVictor MerckléScore: 3,222Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 06:323,17135,568,60320,187,0008,672,00093,110,272
2May 5, 2026 06:323,19335,604,36920,254,0008,803,00093,143,040
3May 5, 2026 06:323,20335,765,65120,346,0008,809,00093,089,792
4May 5, 2026 06:323,22136,384,16520,520,0008,792,00093,077,504
5May 5, 2026 06:323,22235,602,91220,534,0008,792,00093,065,216
6May 5, 2026 06:323,22336,036,49120,445,0008,887,00093,143,040
7May 5, 2026 06:323,23635,874,95220,628,0008,826,00093,110,272
8May 5, 2026 06:323,24435,257,98720,669,0008,855,00093,093,888
9May 5, 2026 06:323,24637,047,73120,595,0008,950,00093,159,424