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 20, 2026 05:45olliecrowolliecrowScore: 4,338Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 05:454,31465,804,55123,149,00016,104,00094,674,944
2Mar 20, 2026 05:454,31964,385,66223,180,00016,125,00094,547,968
3Mar 20, 2026 05:454,32759,838,50223,223,00016,155,00094,547,968
4Mar 20, 2026 05:454,33769,106,45925,297,00014,166,00094,793,728
5Mar 20, 2026 05:454,33866,743,20123,283,00016,197,00094,670,848
6Mar 20, 2026 05:454,34964,296,81118,800,00020,779,00094,547,968
7Mar 20, 2026 05:454,61766,774,34424,009,00018,006,00094,547,968
8Mar 20, 2026 05:454,63472,719,72623,092,00019,076,00094,679,040
9Mar 20, 2026 05:454,64663,619,86321,632,00020,649,00094,547,968