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 21, 2026 10:20limanjun99limanjun99Score: 3,804Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 10:223,75166,585,16825,102,0009,037,00093,122,560
2Apr 21, 2026 10:223,76455,652,65825,190,0009,068,00092,889,088
3Apr 21, 2026 10:223,78064,537,11724,286,00010,119,00093,192,192
4Apr 21, 2026 10:223,78458,416,50826,335,0008,103,00092,901,376
5Apr 21, 2026 10:223,80466,378,46824,730,0009,892,00092,868,608
6Apr 21, 2026 10:223,81851,409,56824,817,0009,927,00092,835,840
7Apr 21, 2026 10:223,81861,567,30224,819,0009,927,00092,925,952
8Apr 21, 2026 10:223,82359,049,16124,853,0009,941,00092,860,416
9Apr 21, 2026 10:223,85948,528,92326,093,0009,032,00092,958,720