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 31, 2025 15:33KeefeKeefeScore: 21,294Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2025 23:5421,226216,743,331173,140,00020,016,00094,666,752
2May 1, 2025 23:5421,265216,973,193169,569,00023,939,00094,666,752
3May 1, 2025 23:5421,268218,833,057174,585,00018,954,00094,666,752
4May 1, 2025 23:5421,273219,613,826175,619,00017,961,00094,633,984
5May 1, 2025 23:5421,275220,559,460170,650,00022,952,00094,654,464
6May 1, 2025 23:5421,288219,160,685172,755,00020,970,00094,543,872
7May 31, 2025 15:3321,294218,279,739171,800,00021,974,00094,658,560
8May 1, 2025 23:5421,317216,516,572172,985,00020,998,00094,539,776
9May 1, 2025 23:5421,356222,069,968173,410,00020,928,00094,564,352
10May 31, 2025 15:3321,393217,592,494171,711,00022,961,00094,666,752
11May 1, 2025 23:5421,407218,614,238172,829,00021,978,00094,793,728
12May 31, 2025 15:3321,517222,359,208173,829,00021,978,00094,711,808