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 14:49marko1597marko1597Score: 5,800Success
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 14:595,75762,171,55031,579,00020,812,00094,396,416stderr
2Aug 14, 2026 14:595,76762,341,22331,547,00020,941,00094,396,416stderr
3Aug 14, 2026 14:595,77462,297,85331,573,00020,974,00094,396,416stderr
4Aug 14, 2026 14:595,78962,555,96131,523,00021,165,00094,396,416stderr
5Aug 14, 2026 14:595,80062,574,27231,680,00021,108,00094,396,416stderr
6Aug 14, 2026 14:595,80862,668,29531,667,00021,188,00094,396,416stderr
7Aug 14, 2026 14:595,81362,684,76631,716,00021,191,00094,396,416stderr
8Aug 14, 2026 14:595,81862,705,89931,634,00021,311,00094,396,416stderr
9Aug 14, 2026 14:595,82962,905,77031,738,00021,307,00094,396,416stderr