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 listJul 28, 2024 13:40Yuriy LyfenkoYuriy LyfenkoScore: 3,457Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2024 13:413,127654,543,21120,329,0008,131,00092,930,048
2Jul 28, 2024 13:403,131657,279,32520,353,0008,141,00093,028,352
3Jul 28, 2024 13:413,149658,715,04219,763,0008,893,00093,155,328
4Jul 28, 2024 13:403,152660,756,97220,771,0007,912,00092,909,568
5Jul 28, 2024 13:413,155656,346,38220,511,0008,204,00092,893,184
6Jul 28, 2024 13:413,285687,380,96829,892,941094,601,216
7Jul 28, 2024 13:403,289685,405,66929,929,140094,642,176
8Jul 28, 2024 13:403,292682,346,04229,961,071094,633,984
9Jul 28, 2024 13:413,302694,079,18430,046,382094,720,000
10Jul 28, 2024 13:413,303691,982,12930,059,935094,638,080
11Jul 28, 2024 13:403,310689,606,97030,124,530094,597,120
12Jul 28, 2024 13:403,453654,116,15923,045,0008,380,00092,962,816
13Jul 28, 2024 13:413,457653,915,38422,020,0009,437,00092,958,720
14Jul 28, 2024 13:414,167659,302,55023,949,00013,970,00093,192,192
15Jul 28, 2024 13:404,516663,967,11225,057,00016,036,00093,175,808
16Jul 28, 2024 13:415,778681,284,90525,795,00026,787,00093,282,304
17Jul 28, 2024 13:406,021678,533,21119,279,00035,514,00093,278,208
18Jul 28, 2024 13:406,748681,785,97235,821,00025,586,00093,327,360
19Jul 28, 2024 13:406,769693,368,13534,772,00026,824,00093,323,264
20Jul 28, 2024 13:406,769686,831,81022,217,00039,385,00093,327,360
21Jul 28, 2024 13:406,828683,768,46730,064,00032,068,00093,323,264
22Jul 28, 2024 13:416,850686,295,48525,134,00037,198,00093,319,168
23Jul 28, 2024 13:416,864685,098,59332,237,00030,222,00093,323,264
24Jul 28, 2024 13:416,883687,328,01230,307,00032,328,00093,323,264