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 listAug 31, 2024 21:41Yuriy LyfenkoYuriy LyfenkoScore: 5,472Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 31, 2024 21:413,079650,500,15720,757,0007,265,00092,835,840
2Aug 31, 2024 21:413,086653,855,15720,058,0008,023,00093,167,616
3Aug 31, 2024 21:413,091649,363,68319,792,0008,333,00092,971,008
4Aug 31, 2024 21:413,101649,300,56218,810,0009,405,00092,864,512
5Aug 31, 2024 21:413,102648,126,29520,908,0007,317,00092,925,952
6Aug 31, 2024 21:414,623668,164,93222,035,00020,032,00093,081,600
7Aug 31, 2024 21:415,472674,231,98127,885,00021,909,00093,126,656
8Aug 31, 2024 21:415,961677,750,97828,126,00026,117,00093,102,080
9Aug 31, 2024 21:416,786685,467,32225,895,00035,855,00093,085,696
10Aug 31, 2024 21:416,789686,514,55921,268,00040,511,00093,323,264
11Aug 31, 2024 21:416,789685,613,75334,436,00027,346,00093,319,168
12Aug 31, 2024 21:416,812683,197,04028,993,00032,992,00093,323,264