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 17:52TudyMTudyMScore: 8,372Success
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 17:588,31491,156,46958,757,00016,902,00094,633,984
2May 3, 2026 17:588,35792,208,67458,448,00017,605,00094,654,464
3May 3, 2026 17:588,36091,435,08159,425,00016,657,00094,638,080
4May 3, 2026 17:588,37192,544,91358,700,00017,479,00094,638,080
5May 3, 2026 17:588,37291,771,92159,417,00016,775,00094,642,176
6May 3, 2026 17:588,38994,668,55559,458,00016,883,00094,633,984
7May 3, 2026 17:588,39194,418,45558,910,00017,456,00094,633,984
8May 3, 2026 17:588,39594,651,15159,405,00016,990,00094,638,080
9May 3, 2026 17:588,41492,676,44658,947,00017,621,00094,638,080