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:20TudyMTudyMScore: 8,376Success
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:268,36292,104,25459,156,00016,946,00094,629,888
2May 3, 2026 18:268,36796,147,21059,425,00016,721,00094,633,984
3May 3, 2026 18:268,36892,229,74659,377,00016,772,00094,633,984
4May 3, 2026 18:268,37490,229,68659,254,00016,958,00094,638,080
5May 3, 2026 18:268,37692,149,98659,392,00016,834,00094,638,080
6May 3, 2026 18:268,38091,951,84258,723,00017,537,00094,625,792
7May 3, 2026 18:268,38290,012,43759,308,00016,971,00094,633,984
8May 3, 2026 18:268,38793,711,95459,387,00016,939,00094,625,792
9May 3, 2026 18:268,40892,853,68659,677,00016,843,00094,642,176