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 00:50KeefeKeefeScore: 41,759Success
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 00:5041,684405,163,928357,365,00021,960,00094,666,752
2May 1, 2025 00:5041,717402,715,625354,652,00024,975,00094,748,672
3May 1, 2025 00:5041,718404,287,135359,652,00019,980,00094,666,752
4May 1, 2025 00:5041,743401,020,484357,868,00021,991,00094,732,288
5May 1, 2025 00:5041,759407,109,224358,011,00022,000,00094,670,848
6May 1, 2025 00:5041,778406,758,627359,173,00021,010,00094,670,848
7May 1, 2025 00:5041,786411,517,854357,235,00023,015,00094,666,752
8May 1, 2025 00:5041,795400,171,791357,378,00022,960,00094,740,480
9May 1, 2025 00:5041,807408,199,798359,477,00020,969,00094,736,384