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 listJul 30, 2026 02:05Andrew TsibinAndrew TsibinScore: 5,810Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 30, 2026 02:115,78462,757,08730,547,00022,089,00092,917,760
2Jul 30, 2026 02:115,78962,758,77830,056,00022,626,00092,958,720
3Jul 30, 2026 02:115,79162,791,90830,201,00022,498,00092,934,144
4Jul 30, 2026 02:115,79662,894,60730,207,00022,537,00092,962,816
5Jul 30, 2026 02:115,81062,944,05330,194,00022,686,00092,958,720
6Jul 30, 2026 02:115,88965,155,00630,495,00023,099,00092,848,128
7Jul 30, 2026 02:115,93964,046,59730,269,00023,779,00092,958,720
8Jul 30, 2026 02:116,00564,720,57930,330,00024,322,00092,930,048
9Jul 30, 2026 02:116,05865,273,70830,487,00024,642,00092,971,008