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 15, 2026 21:57marko1597marko1597Error
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 18:34Tomislav Tunkovic35.92CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 18:4009,397,81401,198,00028,672EOFstderr
2Sep 4, 2026 18:4009,329,54901,219,00032,768EOFstderr
3Sep 4, 2026 18:4009,312,40301,162,00028,672EOFstderr
4Aug 15, 2026 22:033,60641,144,23824,538,0008,278,00092,762,112stderr
5Aug 15, 2026 22:033,61741,216,97024,574,0008,346,00092,762,112stderr
6Aug 15, 2026 22:033,61941,263,29124,613,0008,327,00092,766,208stderr
7Aug 15, 2026 22:033,62242,221,75524,607,0008,354,00092,745,728stderr
8Aug 15, 2026 22:033,62641,324,72124,664,0008,337,00092,708,864stderr
9Aug 15, 2026 22:033,63442,110,17124,734,0008,339,00092,717,056stderr
10Aug 15, 2026 22:033,63541,424,69324,650,0008,434,00092,766,208stderr
11Aug 15, 2026 22:033,64342,272,63724,697,0008,456,00092,741,632stderr
12Aug 15, 2026 22:033,64342,704,51724,692,0008,464,00092,721,152stderr