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:08A_ShamanA_ShamanScore: 91,125Success
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:1491,050838,157,604735,762,00092,796,000171,991,040
2Jul 1, 2026 21:1491,072838,478,688735,762,00093,001,000169,893,888
3Jul 1, 2026 21:1491,083838,405,433735,610,00093,250,000171,991,040
4Jul 1, 2026 21:1491,110838,637,436735,935,00093,169,000171,991,040
5Jul 1, 2026 21:1491,125838,774,683736,041,00093,202,000171,991,040
6Jul 1, 2026 21:1491,150839,404,975735,621,00093,850,000171,991,040
7Jul 1, 2026 21:1491,171839,204,505735,371,00094,290,000171,991,040
8Jul 1, 2026 21:1491,203839,465,373735,721,00094,229,000169,893,888
9Jul 1, 2026 21:1491,251839,900,603737,154,00093,232,000169,893,888