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 16, 2026 23:11Tomislav TunkovicTomislav TunkovicScore: 13,292Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 17, 2026 04:2113,277129,640,300106,208,00014,617,00092,725,248
2Aug 17, 2026 04:2113,283129,518,254106,203,00014,678,00092,864,512
3Aug 17, 2026 04:2113,284129,399,922106,212,00014,681,00092,729,344
4Aug 17, 2026 04:2113,288130,105,693106,228,00014,699,00092,778,496
5Aug 17, 2026 04:2113,292129,377,579106,255,00014,708,00092,729,344
6Aug 17, 2026 04:2113,303129,531,062106,229,00014,833,00092,762,112
7Aug 17, 2026 04:2113,304129,545,553106,318,00014,749,00092,803,072
8Aug 17, 2026 04:2113,311129,552,007106,324,00014,815,00092,835,840
9Aug 17, 2026 04:2113,312130,258,298106,350,00014,794,00092,782,592