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 listMay 3, 2026 15:01TudyMTudyMScore: 8,721Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 15:118,70496,011,03361,815,00017,395,00094,646,272
2May 3, 2026 15:118,71294,217,61761,836,00017,444,00094,633,984
3May 3, 2026 15:118,72095,090,23261,600,00017,756,00094,638,080
4May 3, 2026 15:118,72195,492,26361,848,00017,521,00094,638,080
5May 3, 2026 15:118,72194,681,09962,071,00017,296,00094,642,176
6May 3, 2026 15:118,72497,032,23462,002,00017,390,00094,650,368
7May 3, 2026 15:118,73293,841,88062,027,00017,438,00094,629,888
8May 3, 2026 15:118,74495,249,45962,017,00017,556,00094,633,984
9May 3, 2026 15:118,74696,966,64661,968,00017,621,00094,629,888