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 14, 2026 19:36marko1597marko1597Score: 4,809Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 20:014,78351,939,22431,495,00012,039,00092,794,880stderr
2Aug 14, 2026 20:014,80552,257,68231,521,00012,206,00092,729,344stderr
3Aug 14, 2026 20:014,80652,091,68731,581,00012,159,00092,729,344stderr
4Aug 14, 2026 20:014,80652,136,98131,527,00012,214,00092,766,208stderr
5Aug 14, 2026 20:014,80952,215,60431,641,00012,127,00092,762,112stderr
6Aug 14, 2026 20:014,81952,353,42031,601,00012,253,00092,717,056stderr
7Aug 14, 2026 20:014,82253,079,38031,558,00012,328,00092,700,672stderr
8Aug 14, 2026 20:014,84152,543,59831,654,00012,404,00092,770,304stderr
9Aug 14, 2026 20:014,84252,461,62131,781,00012,284,00092,729,344stderr