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 listApr 22, 2026 05:47olliecrowolliecrowScore: 5,189Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 05:495,12753,735,31125,813,00020,849,00094,605,312
2Apr 22, 2026 05:495,13153,903,02620,866,00025,834,00094,588,928
3Apr 22, 2026 05:495,13753,758,23420,887,00025,861,00094,601,216
4Apr 22, 2026 05:495,17153,900,20028,038,00019,025,00094,748,672
5Apr 22, 2026 05:495,18953,954,73927,131,00020,097,00094,593,024
6Apr 22, 2026 05:495,19654,341,01528,170,00019,115,00094,584,832
7Apr 22, 2026 05:495,22953,908,25327,760,00019,829,00094,593,024
8Apr 22, 2026 05:495,26353,965,51922,953,00024,949,00094,597,120
9Apr 22, 2026 05:495,26753,877,66723,968,00023,968,00094,605,312