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 30, 2026 02:34Andrew TsibinAndrew TsibinScore: 5,780Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 30, 2026 02:405,68961,838,23230,092,00021,682,00092,880,896
2Jul 30, 2026 02:405,69462,678,83030,246,00021,576,00092,913,664
3Jul 30, 2026 02:405,77562,610,12130,092,00022,462,00092,995,584
4Jul 30, 2026 02:405,77762,648,12130,143,00022,428,00092,938,240
5Jul 30, 2026 02:405,78063,431,73930,603,00022,004,00092,966,912
6Jul 30, 2026 02:405,78062,670,29130,101,00022,504,00092,909,568
7Jul 30, 2026 02:405,90264,515,28530,031,00023,679,00092,930,048
8Jul 30, 2026 02:405,99465,433,23630,437,00024,112,00092,987,392
9Jul 30, 2026 02:406,02465,578,38230,696,00024,123,00092,942,336