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 01:22Andrew TsibinAndrew TsibinScore: 6,132Success
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 01:275,85363,353,62536,792,00016,478,00094,392,320
2Jul 30, 2026 01:275,85863,571,62636,854,00016,456,00094,392,320
3Jul 30, 2026 01:275,90663,780,11737,133,00016,620,00094,392,320
4Jul 30, 2026 01:276,12565,871,09736,268,00019,477,00092,909,568
5Jul 30, 2026 01:276,13265,895,42535,929,00019,873,00092,794,880
6Jul 30, 2026 01:276,19966,491,39835,800,00020,611,00092,848,128
7Jul 30, 2026 01:276,42168,595,48536,235,00022,200,00092,958,720
8Jul 30, 2026 01:276,42568,516,38736,090,00022,378,00092,979,200
9Jul 30, 2026 01:276,65970,736,57635,726,00024,877,00092,946,432