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 listNov 21, 2025 07:03Martin StensgårdMartin StensgårdScore: 1,008,108Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 21, 2025 07:031,004,5379,178,742,2958,612,847,000528,438,00094,588,928
2Nov 21, 2025 07:031,006,2489,193,783,8008,677,385,000479,468,00094,670,848
3Nov 21, 2025 07:031,006,5219,191,349,3968,664,751,000494,586,00094,810,112
4Nov 21, 2025 07:031,007,0839,200,364,7698,676,960,000487,492,00094,593,024
5Nov 21, 2025 07:031,008,1089,208,090,6408,655,250,000518,535,00094,707,712
6Nov 21, 2025 07:031,008,1919,217,729,0838,674,058,000500,484,00094,695,424
7Nov 21, 2025 07:031,013,8669,265,011,0888,665,716,000560,464,00094,621,696
8Nov 21, 2025 07:031,031,9209,429,133,9178,791,077,000599,391,00094,695,424
9Nov 21, 2025 07:031,044,7729,540,553,4618,858,014,000649,414,00094,810,112