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 listAug 15, 2026 08:36Tomislav TunkovicTomislav TunkovicScore: 2,696Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 08:432,68732,874,56215,888,0008,572,00092,798,976
2Aug 15, 2026 08:432,68932,887,42015,777,0008,694,00092,774,400
3Aug 15, 2026 08:432,69432,861,76915,784,0008,737,00092,782,592
4Aug 15, 2026 08:432,69532,896,48915,931,0008,594,00092,766,208
5Aug 15, 2026 08:432,69632,890,98115,985,0008,551,00092,704,768
6Aug 15, 2026 08:432,69633,590,61815,991,0008,551,00092,737,536
7Aug 15, 2026 08:432,72133,156,12516,060,0008,702,00092,733,440
8Aug 15, 2026 08:432,72233,139,02816,078,0008,700,00092,749,824
9Aug 15, 2026 08:432,72233,230,28816,088,0008,688,00092,766,208