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:16A_ShamanA_ShamanScore: 75,774Success
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:2275,476696,217,977628,928,00057,906,000169,893,888
2Jul 1, 2026 22:2275,506696,932,364629,198,00057,911,000169,893,888
3Jul 1, 2026 22:2275,522696,577,431629,497,00057,757,000169,893,888
4Jul 1, 2026 22:2275,586697,167,409625,746,00062,091,000169,893,888
5Jul 1, 2026 22:2275,774698,935,440630,573,00058,977,000171,991,040
6Jul 1, 2026 22:2275,949700,623,979633,606,00057,538,000171,991,040
7Jul 1, 2026 22:2276,000701,029,410629,582,00062,019,000171,991,040
8Jul 1, 2026 22:2276,044701,390,406628,771,00063,235,000169,893,888
9Jul 1, 2026 22:2276,136702,300,953629,728,00063,116,000169,893,888