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 18, 2026 05:47M-RochatM-RochatScore: 6,149Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 05:596,13165,031,60547,486,0008,309,00092,729,344
2May 18, 2026 05:596,13664,978,32147,536,0008,304,00092,700,672
3May 18, 2026 05:596,14067,789,49647,522,0008,358,00092,758,016
4May 18, 2026 05:596,14865,067,69047,525,0008,424,00092,725,248
5May 18, 2026 05:596,14965,980,08247,563,0008,393,00092,778,496
6May 18, 2026 05:596,15265,331,22447,587,0008,401,00092,786,688
7May 18, 2026 05:596,15765,174,09547,547,0008,490,00092,745,728
8May 18, 2026 05:596,15765,204,87747,635,0008,401,00092,770,304
9May 18, 2026 05:596,16267,300,54947,589,0008,490,00092,803,072