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 15:56TudyMTudyMScore: 8,643Success
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 16:068,62093,706,34961,813,00016,635,00094,633,984
2May 3, 2026 16:068,63297,919,08761,209,00017,343,00094,633,984
3May 3, 2026 16:068,63396,870,85561,031,00017,534,00094,638,080
4May 3, 2026 16:068,64297,113,44061,430,00017,217,00094,633,984
5May 3, 2026 16:068,64394,197,90661,162,00017,492,00094,646,272
6May 3, 2026 16:068,65493,034,98761,359,00017,400,00094,646,272
7May 3, 2026 16:068,66992,608,60361,592,00017,299,00094,633,984
8May 3, 2026 16:068,67193,409,35261,648,00017,262,00094,646,272
9May 3, 2026 16:068,68195,200,89961,648,00017,351,00094,646,272