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 00:57Andrew TsibinAndrew TsibinScore: 5,740Success
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:025,50160,246,65133,609,00016,454,00094,392,320
2Jul 30, 2026 01:025,53560,540,57333,659,00016,716,00094,392,320
3Jul 30, 2026 01:025,54660,529,36933,645,00016,827,00094,392,320
4Jul 30, 2026 01:025,64761,436,96633,196,00018,194,00092,827,648
5Jul 30, 2026 01:025,74062,299,30233,202,00019,037,00092,790,784
6Jul 30, 2026 01:026,10665,719,62133,459,00022,114,00092,876,800
7Jul 30, 2026 01:026,14065,984,85333,009,00022,867,00092,979,200
8Jul 30, 2026 01:026,16166,236,16932,991,00023,076,00093,003,776
9Jul 30, 2026 01:026,33369,204,69033,258,00024,380,00092,942,336