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 listApr 16, 2026 02:08olliecrowolliecrowScore: 4,324Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 16, 2026 02:084,30471,458,69921,089,00018,076,00094,666,752
2Apr 16, 2026 02:084,31175,722,28720,119,00019,113,00094,674,944
3Apr 16, 2026 02:084,31659,821,18123,164,00016,114,00094,674,944
4Apr 16, 2026 02:084,31962,083,43423,177,00016,123,00094,552,064
5Apr 16, 2026 02:084,32466,280,32524,217,00015,135,00094,679,040
6Apr 16, 2026 02:084,32968,345,56324,242,00015,151,00094,552,064
7Apr 16, 2026 02:084,33361,349,27523,256,00016,178,00094,679,040
8Apr 16, 2026 02:084,33764,275,92523,679,00015,786,00094,789,632
9Apr 16, 2026 02:084,36566,820,80425,822,00013,904,00094,552,064