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 listDec 31, 2024 06:12Mikhail ShirokovMikhail ShirokovScore: 28,476Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 31, 2024 06:1228,357280,878,503204,039,00054,010,000111,525,888
2Dec 31, 2024 06:1228,380290,251,553206,208,00052,052,000111,321,088
3Dec 31, 2024 06:1228,413286,077,194197,659,00060,895,000111,394,816
4Dec 31, 2024 06:1228,413289,676,635203,649,00054,905,000111,464,448
5Dec 31, 2024 06:1228,476284,219,544199,102,00060,030,000111,378,432
6Dec 31, 2024 06:1228,478284,222,792198,114,00061,035,000111,468,544
7Dec 31, 2024 06:1228,492283,469,113200,211,00059,062,000111,390,720
8Dec 31, 2024 06:1228,496293,771,005202,247,00057,069,000111,407,104
9Dec 31, 2024 06:1228,561281,623,829206,925,00052,980,000111,542,272