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 listMar 10, 2026 19:25Josu San MartinJosu San MartinScore: 3,972Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 19:253,93861,054,17116,921,00018,911,00094,679,040
2Mar 10, 2026 19:253,94760,675,98717,958,00017,958,00094,552,064
3Mar 10, 2026 19:253,94957,356,42320,962,00014,973,00094,670,848
4Mar 10, 2026 19:253,96857,132,02719,057,00017,051,00094,552,064
5Mar 10, 2026 19:253,97260,118,53917,068,00019,076,00094,666,752
6Mar 10, 2026 19:253,97859,293,30318,099,00018,099,00094,552,064
7Mar 10, 2026 19:254,00063,494,88418,202,00018,202,00094,674,944
8Mar 10, 2026 19:254,00165,609,51617,192,00019,214,00094,552,064
9Mar 10, 2026 19:254,00758,710,76520,256,00016,204,00094,552,064