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 26, 2021 16:49Yuriy LyfenkoYuriy LyfenkoScore: 11,104Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 16:5410,897173,815,94799,161,093094,699,520
2May 26, 2021 16:4910,899179,036,50399,183,591094,703,616
3May 26, 2021 16:4910,936162,534,49899,519,523094,695,424
4May 26, 2021 16:5410,964190,408,63099,775,285094,699,520
5May 26, 2021 16:5110,994184,540,644100,046,296094,695,424
6May 26, 2021 16:5110,996163,102,105100,059,293094,695,424
7May 26, 2021 16:5111,003172,828,620100,127,697094,695,424
8May 26, 2021 16:5411,006162,931,399100,158,924094,732,288
9May 26, 2021 16:4911,053133,692,05479,671,00020,913,00094,781,440
10May 26, 2021 16:5411,058129,495,27980,703,00019,926,00094,613,504
11May 26, 2021 16:4911,090125,053,12275,940,00024,980,00094,777,344
12May 26, 2021 16:5411,097124,387,81582,989,00017,997,00094,781,440
13May 26, 2021 16:4911,103131,273,75683,028,00018,006,00094,781,440
14May 26, 2021 16:5411,104125,990,94284,037,00017,007,00094,609,408
15May 26, 2021 16:5411,120122,483,73284,162,00017,032,00092,938,240
16May 26, 2021 16:5411,121125,935,53180,163,00021,042,00094,613,504
17May 26, 2021 16:4911,123122,935,98878,169,00023,049,00094,613,504
18May 26, 2021 16:4911,137133,091,28883,286,00018,062,00094,781,440
19May 26, 2021 16:5411,140122,152,50482,303,00019,070,00094,613,504
20May 26, 2021 16:4911,151130,179,55183,393,00018,085,00094,785,536
21May 26, 2021 16:4911,183164,931,545101,764,556094,699,520
22May 26, 2021 16:4911,383129,854,63682,464,00021,118,00093,044,736
23May 26, 2021 16:4911,450130,556,84482,151,00022,040,00093,212,672
24May 26, 2021 16:5411,499128,604,52882,503,00022,135,00093,204,480
25May 26, 2021 16:5411,568129,388,01779,201,00026,066,00093,306,880
26May 26, 2021 16:5411,631132,157,78580,877,00024,962,00093,306,880
27May 26, 2021 16:4911,735131,923,16684,833,00021,956,00093,306,880