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:34TudyMTudyMScore: 8,849Success
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:448,82499,172,47563,057,00017,244,00094,638,080
2May 3, 2026 15:448,829100,808,85663,066,00017,284,00094,629,888
3May 3, 2026 15:448,83095,586,52763,027,00017,328,00094,633,984
4May 3, 2026 15:448,83796,212,49462,708,00017,711,00094,629,888
5May 3, 2026 15:448,84996,687,48163,027,00017,500,00094,646,272
6May 3, 2026 15:448,85196,178,57163,030,00017,515,00094,629,888
7May 3, 2026 15:448,85496,249,28663,119,00017,455,00094,629,888
8May 3, 2026 15:448,86496,261,92363,144,00017,522,00094,638,080
9May 3, 2026 15:448,86897,434,06563,168,00017,535,00094,629,888