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 28, 2026 09:57TudyMTudyMScore: 18,012Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 09:5817,971179,405,536138,459,00025,083,00094,732,288
2Apr 28, 2026 09:5817,980182,363,579141,671,00021,949,00094,633,984
3Apr 28, 2026 09:5817,988178,055,346137,741,00025,951,00094,691,328
4Apr 28, 2026 09:5817,992181,354,411140,769,00022,962,00094,638,080
5Apr 28, 2026 09:5818,012184,107,128142,925,00020,988,00094,633,984
6Apr 28, 2026 09:5818,020181,561,149140,987,00022,997,00094,588,928
7Apr 28, 2026 09:5818,024185,329,806141,019,00023,003,00094,633,984
8Apr 28, 2026 09:5818,032180,061,665142,080,00022,012,00094,629,888
9Apr 28, 2026 09:5818,040182,416,692139,143,00025,025,00094,625,792