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 listSep 14, 2026 21:39Andrew EpsteinAndrew EpsteinScore: 4,625Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 21:554,61650,684,40933,386,0008,628,00092,803,072
2Sep 14, 2026 21:554,61850,704,96933,421,0008,605,00092,753,920
3Sep 14, 2026 21:554,62050,846,49733,377,0008,674,00092,839,936
4Sep 14, 2026 21:554,62350,799,25933,447,0008,628,00092,798,976
5Sep 14, 2026 21:554,62550,809,96333,453,0008,642,00092,774,400
6Sep 14, 2026 21:554,62952,910,48533,367,0008,763,00092,745,728
7Sep 14, 2026 21:554,63051,466,64533,301,0008,836,00092,753,920
8Sep 14, 2026 21:554,63250,843,14433,482,0008,670,00092,794,880
9Sep 14, 2026 21:554,67560,228,54333,649,0008,901,00092,782,592