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 1, 2025 11:12KeefeKeefeScore: 21,648Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2025 11:1221,591218,301,084176,531,00019,947,00094,658,560
2May 1, 2025 11:1221,625222,593,418173,817,00022,975,00094,679,040
3May 1, 2025 11:1221,626224,806,509177,820,00018,980,00094,720,000
4May 1, 2025 11:1221,628219,213,630174,838,00021,979,00094,785,536
5May 1, 2025 11:1221,648225,136,976178,001,00019,000,00094,564,352
6May 1, 2025 11:1221,651226,031,318177,024,00020,002,00094,625,792
7May 1, 2025 11:1221,673226,504,439175,198,00022,024,00094,658,560
8May 1, 2025 11:1221,677223,267,953177,236,00020,026,00094,654,464
9May 1, 2025 11:1221,686228,851,381173,298,00024,041,00094,703,616