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 26, 2024 22:06Yuriy LyfenkoYuriy LyfenkoScore: 3,773Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 26, 2024 22:063,584659,015,73623,721,0008,895,00093,216,768
2Jul 26, 2024 22:063,594669,470,71622,792,0009,909,00093,188,096
3Jul 26, 2024 22:063,595661,937,68324,533,0008,177,00093,134,848
4Jul 26, 2024 22:063,595664,184,26022,801,0009,913,00093,179,904
5Jul 26, 2024 22:063,596657,480,56424,542,0008,180,00093,081,600
6Jul 26, 2024 22:063,770686,446,33534,303,434094,650,368
7Jul 26, 2024 22:063,773700,228,47334,336,213094,609,408
8Jul 26, 2024 22:063,783694,898,55834,426,323094,609,408
9Jul 26, 2024 22:066,049676,022,44235,030,00020,017,00093,122,560
10Jul 26, 2024 22:066,895686,774,08631,868,00030,872,00093,249,536
11Jul 26, 2024 22:066,994693,545,16028,286,00035,358,00093,335,552
12Jul 26, 2024 22:067,226691,404,33629,337,00036,419,00093,233,152