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 listApr 22, 2024 02:24Yuriy LyfenkoYuriy LyfenkoScore: 3,622Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2024 02:263,449553,328,06521,260,00010,124,00092,876,800
2Apr 22, 2024 02:263,452560,217,60321,278,00010,132,00092,897,280
3Apr 22, 2024 02:243,466560,667,74823,402,0008,140,00092,852,224
4Apr 22, 2024 02:263,470557,591,34625,463,0006,111,00092,958,720
5Apr 22, 2024 02:243,477559,492,52021,756,0009,889,00092,909,568
6Apr 22, 2024 02:263,480557,573,84824,741,0006,927,00092,938,240
7Apr 22, 2024 02:263,482559,398,09722,774,0008,911,00092,876,800
8Apr 22, 2024 02:243,484561,113,73824,767,0006,934,00092,917,760
9Apr 22, 2024 02:263,486557,973,00321,812,0009,914,00092,897,280
10Apr 22, 2024 02:243,493560,750,09521,850,0009,932,00092,868,608
11Apr 22, 2024 02:243,497560,490,58522,876,0008,951,00092,938,240
12Apr 22, 2024 02:243,622591,422,66732,958,153094,605,312
13Apr 22, 2024 02:263,622584,250,38932,959,849094,609,408
14Apr 22, 2024 02:263,626613,090,52232,999,156094,605,312
15Apr 22, 2024 02:243,628603,311,82333,015,579094,609,408
16Apr 22, 2024 02:263,637601,218,73933,098,042094,605,312
17Apr 22, 2024 02:243,639606,217,37933,111,476094,605,312
18Apr 22, 2024 02:244,309566,439,98718,097,00021,113,00093,061,120
19Apr 22, 2024 02:265,775582,563,88929,310,00023,245,00093,130,752
20Apr 22, 2024 02:265,876585,634,72224,215,00029,260,00093,249,536
21Apr 22, 2024 02:246,176577,531,78835,127,00021,076,00093,110,272
22Apr 22, 2024 02:247,134589,242,23634,956,00029,962,00093,327,360
23Apr 22, 2024 02:267,225594,666,02632,876,00032,876,00093,319,168
24Apr 22, 2024 02:247,231588,515,62129,910,00035,892,00093,323,264