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 listMar 13, 2026 12:05Dominique GarmierDominique GarmierScore: 25,369Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 13, 2026 12:0525,306252,561,208214,339,00015,950,00094,539,776
2Mar 13, 2026 12:0525,314256,697,439207,421,00022,936,00094,793,728
3Mar 13, 2026 12:0525,352261,477,023209,734,00020,973,00094,797,824
4Mar 13, 2026 12:0525,358256,919,125212,777,00017,981,00094,556,160
5Mar 13, 2026 12:0525,369251,085,052217,869,00012,992,00094,621,696
6Mar 13, 2026 12:0525,371257,931,374212,889,00017,990,00094,785,536
7Mar 13, 2026 12:0525,377256,979,162212,939,00017,994,00094,785,536
8Mar 13, 2026 12:0525,405262,767,002211,260,00019,930,00094,785,536
9Mar 13, 2026 12:0525,447257,285,297215,595,00015,970,00094,547,968