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:16KeefeKeefeScore: 65,140Success
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:1664,929619,373,404573,862,00016,995,00094,769,152
2Jan 29, 2025 22:1665,007619,514,502578,572,00012,990,00094,801,920
3Jan 29, 2025 22:1665,059616,222,261577,036,00015,000,00094,556,160
4Jan 29, 2025 22:1665,089622,129,895575,332,00016,980,00094,552,064
5Jan 29, 2025 22:1665,140620,290,543573,784,00018,992,00094,556,160
6Jan 29, 2025 22:1665,186618,867,350574,221,00018,974,00094,654,464
7Jan 29, 2025 22:1665,205622,323,611574,391,00018,979,00094,625,792
8Jan 29, 2025 22:1666,008626,322,222584,678,00015,991,00094,654,464
9Jan 29, 2025 22:1666,535631,547,593589,479,00015,985,00094,797,824