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 listJul 28, 2023 22:14Yurkov AlekseyYurkov AlekseyError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2023 22:3900000Error: No answer to stdout. Died or killed?
2Jul 28, 2023 22:395,967136,300,01054,296,158092,573,696
3Jul 28, 2023 22:395,967118,370,14254,298,110092,569,600
4Jul 28, 2023 22:395,976110,268,63854,379,379092,573,696
5Jul 28, 2023 22:145,977127,371,16954,390,342092,561,408
6Jul 28, 2023 22:145,978113,271,87654,403,325092,565,504
7Jul 28, 2023 22:146,012114,269,30254,711,979092,692,480
8Jul 28, 2023 22:3912,726137,819,197100,836,00014,975,00092,700,672
9Jul 28, 2023 22:3912,732141,513,56892,888,00022,972,00092,639,232
10Jul 28, 2023 22:1412,735138,110,64192,910,00022,977,00092,446,720
11Jul 28, 2023 22:1412,739140,185,574102,933,00012,991,00092,471,296
12Jul 28, 2023 22:3912,741139,017,284101,948,00013,992,00092,704,768
13Jul 28, 2023 22:3912,742137,695,60899,962,00015,993,00092,446,720
14Jul 28, 2023 22:1412,745138,091,499102,984,00012,998,00092,450,816
15Jul 28, 2023 22:3912,762140,112,919101,118,00015,017,00092,602,368
16Jul 28, 2023 22:1412,770144,397,697101,306,00014,898,00092,606,464
17Jul 28, 2023 22:3912,778139,175,303106,254,00010,023,00092,688,384
18Jul 28, 2023 22:1412,779139,129,962100,253,00016,040,00092,450,816
19Jul 28, 2023 22:1412,786140,881,547101,434,00014,916,00092,446,720
20Jul 28, 2023 22:3912,829142,015,691103,771,00012,971,00091,926,528
21Jul 28, 2023 22:1412,829142,689,79188,809,00027,939,00091,926,528
22Jul 28, 2023 22:1412,905145,283,957102,383,00015,056,00092,205,056
23Jul 28, 2023 22:3912,962141,825,89598,961,00018,992,00091,947,008
24Jul 28, 2023 22:3913,010144,932,06099,331,00019,063,00092,094,464
25Jul 28, 2023 22:1413,186146,271,98696,998,00022,999,00092,192,768