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 21, 2026 09:42M-RochatM-RochatScore: 9,517Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 21, 2026 09:489,48796,427,24070,000,00016,339,00094,392,320
2May 21, 2026 09:489,49097,371,04770,023,00016,345,00094,392,320
3May 21, 2026 09:489,51196,520,02269,460,00017,093,00094,392,320
4May 21, 2026 09:489,51795,803,18069,485,00017,120,00094,392,320
5May 21, 2026 09:489,51795,852,60469,591,00017,017,00094,392,320
6May 21, 2026 09:489,52095,860,03269,510,00017,125,00094,392,320
7May 21, 2026 09:489,54196,108,78369,625,00017,201,00094,392,320
8May 21, 2026 09:489,55496,294,67469,790,00017,159,00094,392,320
9May 21, 2026 09:489,62696,970,82570,314,00017,285,00094,392,320