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 listMay 22, 2024 00:09Joad NacerJoad NacerScore: 3,676Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2024 00:093,39960,743,09820,956,0009,979,00093,188,096
2May 22, 2024 00:093,44254,343,82821,220,00010,105,00092,942,336
3May 22, 2024 00:093,45560,841,25321,301,00010,143,00092,860,416
4May 22, 2024 00:093,49064,381,38919,848,00011,909,00093,032,448
5May 22, 2024 00:093,50958,014,36919,959,00011,975,00092,872,704
6May 22, 2024 00:093,51161,538,89019,971,00011,982,00093,175,808
7May 22, 2024 00:093,51658,704,10420,998,00010,999,00092,876,800
8May 22, 2024 00:093,52458,623,53320,042,00012,025,00092,925,952
9May 22, 2024 00:093,52658,081,36020,056,00012,033,00092,917,760
10May 22, 2024 00:093,52956,138,82320,073,00012,043,00092,901,376
11May 22, 2024 00:093,64886,270,14733,200,096094,478,336
12May 22, 2024 00:093,658104,790,16833,285,283094,490,624
13May 22, 2024 00:093,67695,457,92333,451,234094,482,432
14May 22, 2024 00:093,679110,651,92933,475,962094,498,816
15May 22, 2024 00:093,68394,913,42333,513,222094,486,528
16May 22, 2024 00:093,702115,233,28233,689,397094,740,480
17May 22, 2024 00:094,60368,421,61121,942,00019,947,00093,265,920
18May 22, 2024 00:094,84768,898,94323,055,00021,050,00093,114,368
19May 22, 2024 00:095,82179,037,59722,988,00029,985,00093,065,216
20May 22, 2024 00:097,41692,243,81525,181,00042,304,00093,184,000
21May 22, 2024 00:097,41895,867,12926,194,00041,306,00093,179,904
22May 22, 2024 00:097,53997,256,91725,223,00043,385,00093,265,920
23May 22, 2024 00:097,59591,833,69325,042,00044,074,00093,167,616
24May 22, 2024 00:097,597100,878,03126,050,00043,083,00093,323,264