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 21, 2026 23:41olliecrowolliecrowScore: 5,721Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 23:455,68458,665,30733,824,00017,907,00094,814,208
2Apr 21, 2026 23:455,69269,614,84733,869,00017,931,00094,748,672
3Apr 21, 2026 23:455,69458,781,63331,892,00019,932,00094,593,024
4Apr 21, 2026 23:455,69858,788,99434,903,00016,953,00094,605,312
5Apr 21, 2026 23:455,72158,764,87937,048,00015,019,00094,605,312
6Apr 21, 2026 23:455,72258,978,29736,055,00016,024,00094,601,216
7Apr 21, 2026 23:455,73459,077,03735,122,00017,059,00094,605,312
8Apr 21, 2026 23:455,74359,166,50935,182,00017,088,00094,601,216
9Apr 21, 2026 23:455,79558,584,64233,833,00018,907,00094,597,120