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 16, 2026 09:46marko1597marko1597Score: 3,130Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 10:053,11536,786,22620,039,0008,310,00092,807,168stderr
2Aug 16, 2026 10:053,11736,789,30520,036,0008,331,00092,758,016stderr
3Aug 16, 2026 10:053,11736,789,47320,017,0008,351,00092,766,208stderr
4Aug 16, 2026 10:053,12836,772,23420,070,0008,399,00092,741,632stderr
5Aug 16, 2026 10:053,13036,970,54220,074,0008,418,00092,762,112stderr
6Aug 16, 2026 10:053,13237,615,63820,129,0008,381,00092,717,056stderr
7Aug 16, 2026 10:053,14437,007,58020,145,0008,466,00092,749,824stderr
8Aug 16, 2026 10:053,14837,101,13220,157,0008,495,00092,790,784stderr
9Aug 16, 2026 10:053,14837,020,41320,195,0008,459,00092,770,304stderr