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 listAug 15, 2026 23:21marko1597marko1597Score: 3,499Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 23:413,47240,009,25523,325,0008,273,00092,758,016stderr
2Aug 15, 2026 23:413,47540,055,11323,338,0008,293,00092,741,632stderr
3Aug 15, 2026 23:413,49140,114,67423,406,0008,366,00092,684,288stderr
4Aug 15, 2026 23:413,49440,875,71223,417,0008,384,00092,753,920stderr
5Aug 15, 2026 23:413,49940,196,42923,535,0008,308,00092,766,208stderr
6Aug 15, 2026 23:413,50640,387,42223,454,0008,455,00092,758,016stderr
7Aug 15, 2026 23:413,50841,713,76523,486,0008,444,00092,790,784stderr
8Aug 15, 2026 23:413,51840,430,64723,654,0008,361,00092,753,920stderr
9Aug 15, 2026 23:413,53040,489,39323,737,0008,389,00092,729,344stderr