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 listJun 23, 2024 16:11AnSaAnSaScore: 5,172Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 23, 2024 16:114,19862,077,54530,161,0008,043,00091,947,008
2Jun 23, 2024 16:114,20461,631,40923,153,00015,100,00091,951,104
3Jun 23, 2024 16:114,20759,247,39817,128,00021,159,00091,942,912
4Jun 23, 2024 16:134,21360,400,87728,252,00010,090,00091,910,144
5Jun 23, 2024 16:134,23569,094,78627,380,00011,155,00091,906,048
6Jun 23, 2024 16:134,24966,674,10723,797,00014,873,00091,897,856
7Jun 23, 2024 16:134,61572,127,71724,998,00016,998,00092,139,520
8Jun 23, 2024 16:114,78479,454,48928,349,00015,187,00092,147,712
9Jun 23, 2024 16:115,140112,073,22546,772,564092,524,544
10Jun 23, 2024 16:115,148105,486,75546,847,346092,655,616
11Jun 23, 2024 16:135,161108,636,85846,966,700092,532,736
12Jun 23, 2024 16:115,163114,054,56646,985,961092,532,736
13Jun 23, 2024 16:135,17278,641,19822,029,00025,033,00092,172,288
14Jun 23, 2024 16:135,183122,057,11147,161,099092,520,448
15Jun 23, 2024 16:135,188125,412,98947,208,636092,516,352
16Jun 23, 2024 16:135,21279,803,43326,237,00021,191,00092,164,096
17Jun 23, 2024 16:115,70080,477,01130,923,00020,948,00092,143,616
18Jun 23, 2024 16:115,92281,310,01330,938,00022,954,00092,114,944
19Jun 23, 2024 16:138,923110,827,21741,102,00040,100,00092,332,032
20Jun 23, 2024 16:119,132109,056,11431,037,00052,063,00092,229,632
21Jun 23, 2024 16:119,135109,256,60134,052,00049,075,00092,360,704
22Jun 23, 2024 16:139,158109,406,65535,144,00048,198,00092,250,112
23Jun 23, 2024 16:139,220114,198,37839,955,00043,950,00092,377,088
24Jun 23, 2024 16:119,277108,025,75838,191,00046,231,00092,479,488