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 16:45TudyMTudyMScore: 8,574Success
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 16:558,56194,477,48561,210,00016,701,00094,629,888
2May 3, 2026 16:558,56491,554,48260,624,00017,310,00094,642,176
3May 3, 2026 16:558,56593,655,76161,249,00016,699,00094,638,080
4May 3, 2026 16:558,57093,737,84961,440,00016,553,00094,642,176
5May 3, 2026 16:558,57493,613,68260,613,00017,417,00094,642,176
6May 3, 2026 16:558,58193,593,19061,400,00016,688,00094,629,888
7May 3, 2026 16:558,58591,349,53061,399,00016,731,00094,633,984
8May 3, 2026 16:558,59791,972,18060,903,00017,330,00094,629,888
9May 3, 2026 16:558,67795,501,52761,653,00017,311,00094,646,272