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 1, 2025 11:07KeefeKeefeScore: 21,646Success
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 11:0721,611221,025,817174,697,00021,961,00094,666,752
2May 1, 2025 11:0721,624223,962,420172,809,00023,973,00094,646,272
3May 1, 2025 11:0721,634224,426,268175,881,00020,985,00094,662,656
4May 1, 2025 11:0721,636221,339,399174,897,00021,987,00094,670,848
5May 1, 2025 11:0721,646225,805,886174,980,00021,997,00094,670,848
6May 1, 2025 11:0721,676223,144,786176,330,00020,920,00094,539,776
7May 1, 2025 11:0721,692227,534,374173,468,00023,926,00094,785,536
8May 1, 2025 11:0721,701223,746,155175,537,00021,942,00094,658,560
9May 1, 2025 11:0721,701224,824,834175,537,00021,942,00094,699,520