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 listJan 29, 2025 22:08KeefeKeefeScore: 65,184Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 29, 2025 22:0864,976622,234,046573,303,00017,978,00094,662,656
2Jan 29, 2025 22:0865,060611,446,034579,042,00013,000,00094,560,256
3Jan 29, 2025 22:0865,144624,439,980574,814,00017,994,00094,658,560
4Jan 29, 2025 22:0865,163619,577,627576,015,00016,970,00094,769,152
5Jan 29, 2025 22:0865,184621,224,571577,169,00016,004,00094,748,672
6Jan 29, 2025 22:0865,213618,705,709577,452,00015,984,00094,769,152
7Jan 29, 2025 22:0865,347628,134,102571,668,00022,986,00094,560,256
8Jan 29, 2025 22:0865,369625,036,419576,859,00017,995,00094,662,656
9Jan 29, 2025 22:0865,445621,050,533580,560,00014,988,00094,556,160