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 21:27A_ShamanA_ShamanScore: 77,714Success
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 21:3477,530715,413,330612,960,00092,566,000171,991,040
2Jul 1, 2026 21:3477,600715,676,037613,025,00093,135,000169,893,888
3Jul 1, 2026 21:3477,618715,942,237612,952,00093,377,000169,893,888
4Jul 1, 2026 21:3477,683717,005,555612,969,00093,955,000169,893,888
5Jul 1, 2026 21:3477,714716,788,288613,524,00093,681,000171,991,040
6Jul 1, 2026 21:3477,746717,460,598614,591,00092,904,000169,893,888
7Jul 1, 2026 21:3477,801717,880,348614,860,00093,135,000169,893,888
8Jul 1, 2026 21:3477,815717,982,474615,259,00092,864,000169,893,888
9Jul 1, 2026 21:3477,861718,481,882614,843,00093,697,000169,893,888