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 18:14TudyMTudyMScore: 8,374Success
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 18:198,33391,571,75158,244,00017,588,00094,642,176
2May 3, 2026 18:198,36791,575,14258,557,00017,586,00094,638,080
3May 3, 2026 18:198,36795,589,12659,149,00016,993,00094,638,080
4May 3, 2026 18:198,37292,025,38059,485,00016,709,00094,650,368
5May 3, 2026 18:198,37494,591,89159,520,00016,687,00094,646,272
6May 3, 2026 18:198,37994,060,73959,509,00016,746,00094,633,984
7May 3, 2026 18:198,39191,780,09058,918,00017,446,00094,646,272
8May 3, 2026 18:198,39192,511,70459,591,00016,768,00094,629,888
9May 3, 2026 18:198,40295,909,21958,819,00017,648,00094,638,080