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 17:32TudyMTudyMScore: 8,530Success
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 17:378,51594,687,78860,784,00016,703,00094,633,984
2May 3, 2026 17:378,51792,906,18160,762,00016,743,00094,629,888
3May 3, 2026 17:378,52294,483,18460,676,00016,880,00094,633,984
4May 3, 2026 17:378,52292,940,34060,764,00016,789,00094,625,792
5May 3, 2026 17:378,53094,152,90460,771,00016,856,00094,621,696
6May 3, 2026 17:378,53693,177,53760,798,00016,884,00094,646,272
7May 3, 2026 17:378,54493,634,74160,932,00016,824,00094,642,176
8May 3, 2026 17:378,55293,917,76060,907,00016,922,00094,621,696
9May 3, 2026 17:378,61994,299,54461,631,00016,803,00094,642,176