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 listJun 11, 2026 16:15Victor MerckléVictor MerckléScore: 2,740Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 16:202,73133,867,51616,107,0008,751,00092,708,864
2Jun 11, 2026 16:202,73234,307,80216,122,0008,745,00092,745,728
3Jun 11, 2026 16:202,73333,891,86516,097,0008,780,00092,766,208
4Jun 11, 2026 16:202,74035,122,27516,153,0008,782,00092,712,960
5Jun 11, 2026 16:202,74033,954,18516,151,0008,789,00092,737,536
6Jun 11, 2026 16:202,74534,040,53316,209,0008,773,00092,766,208
7Jun 11, 2026 16:202,75234,072,98516,179,0008,866,00092,708,864
8Jun 11, 2026 16:202,75634,111,28216,214,0008,866,00092,749,824
9Jun 11, 2026 16:202,76034,504,17516,230,0008,892,00092,749,824