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 01:52Yuriy LyfenkoYuriy LyfenkoScore: 4,652Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 21, 2021 19:024,609563,677,40921,971,00019,973,00094,662,656
2Aug 21, 2021 19:024,610564,488,63523,971,00017,978,00094,646,272
3Apr 22, 2024 01:524,612564,942,44524,982,00016,988,00094,662,656
4Aug 21, 2021 19:024,614567,740,98422,991,00018,992,00094,662,656
5Aug 21, 2021 19:024,618600,708,63842,023,424094,629,888
6Aug 21, 2021 19:024,619595,990,88542,032,134094,752,768
7Apr 22, 2024 01:524,619612,407,57642,034,107094,760,960
8Apr 22, 2024 01:524,631611,640,18442,144,990094,760,960
9Apr 22, 2024 01:524,633569,999,59224,091,00018,068,00094,642,176
10Apr 22, 2024 01:524,642564,984,42623,135,00019,111,00094,662,656
11Aug 21, 2021 19:024,643570,488,91724,143,00018,107,00094,662,656
12Aug 21, 2021 19:024,646605,780,85442,280,447094,756,864
13Apr 22, 2024 01:524,652564,483,12525,200,00017,136,00094,662,656
14Aug 21, 2021 19:024,659571,930,70822,210,00020,191,00094,646,272
15Apr 22, 2024 01:524,659602,864,15242,400,481094,642,176
16Aug 21, 2021 19:024,664571,780,81423,241,00019,199,00094,658,560
17Apr 22, 2024 01:524,669568,560,32825,291,00017,198,00093,089,792
18Apr 22, 2024 01:524,671565,371,90620,239,00022,263,00094,666,752
19Apr 22, 2024 01:524,684568,631,28123,789,00018,833,00094,662,656
20Apr 22, 2024 01:524,690573,219,48323,819,00018,856,00093,085,696
21Apr 22, 2024 01:524,742564,119,42723,083,00020,072,00093,073,408
22Aug 21, 2021 19:024,927567,451,15722,918,00021,922,00093,085,696
23Aug 21, 2021 19:024,957570,049,04024,057,00021,050,00093,085,696
24Aug 21, 2021 19:024,963567,684,90222,078,00023,082,00093,073,408