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 4, 2026 02:03olliecrowolliecrowScore: 11,351Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 02:0311,308124,717,16185,919,00016,984,00094,568,448
2Mar 4, 2026 02:0311,321129,533,90785,021,00018,004,00094,556,160
3Mar 4, 2026 02:0311,334125,954,64786,116,00017,023,00094,793,728
4Mar 4, 2026 02:0311,340127,973,69185,160,00018,034,00094,547,968
5Mar 4, 2026 02:0311,351125,858,74988,254,00015,043,00094,572,544
6Mar 4, 2026 02:0311,354127,764,65489,276,00014,043,00094,801,920
7Mar 4, 2026 02:0311,386130,123,45283,687,00019,925,00094,547,968
8Mar 4, 2026 02:0311,422132,612,55785,947,00017,989,00094,547,968
9Mar 4, 2026 02:0311,434134,078,04085,037,00019,008,00094,568,448