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 30, 2026 05:09Charles CabergsCharles CabergsScore: 4,007Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2026 05:123,98760,493,84518,145,00018,145,00094,605,312
2Apr 30, 2026 05:124,00350,893,96919,227,00017,203,00094,617,600
3Apr 30, 2026 05:124,00356,597,92520,239,00016,191,00094,793,728
4Apr 30, 2026 05:124,00755,311,02416,208,00020,260,00094,806,016
5Apr 30, 2026 05:124,00752,429,65718,236,00018,236,00094,793,728
6Apr 30, 2026 05:124,01455,484,99519,280,00017,250,00094,797,824
7Apr 30, 2026 05:124,01456,906,45718,760,00017,772,00094,801,920
8Apr 30, 2026 05:124,02153,569,46318,791,00017,802,00094,793,728
9Apr 30, 2026 05:124,03552,944,56217,864,00018,856,00094,801,920