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 1, 2026 22:06A_ShamanA_ShamanScore: 48,244Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 22:1248,145448,096,429407,706,00030,419,000171,991,040
2Jul 1, 2026 22:1248,209448,238,813408,489,00030,214,000171,991,040
3Jul 1, 2026 22:1248,220448,381,693408,860,00029,951,000171,991,040
4Jul 1, 2026 22:1248,223448,425,025408,610,00030,222,000169,893,888
5Jul 1, 2026 22:1248,244448,519,094409,084,00029,945,000169,893,888
6Jul 1, 2026 22:1248,265449,094,360408,944,00030,268,000171,991,040
7Jul 1, 2026 22:1248,271448,790,497409,465,00029,805,000171,991,040
8Jul 1, 2026 22:1248,322449,661,710409,224,00030,510,000169,893,888
9Jul 1, 2026 22:1248,959454,998,228415,326,00030,203,000171,991,040