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 26, 2026 16:43Charles CabergsCharles CabergsScore: 4,343Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 26, 2026 16:454,30560,641,59320,094,00019,090,00094,793,728
2Apr 26, 2026 16:454,31055,155,84524,140,00015,088,00094,801,920
3Apr 26, 2026 16:454,31961,418,93322,172,00017,133,00094,801,920
4Apr 26, 2026 16:454,32460,086,73621,188,00018,161,00094,797,824
5Apr 26, 2026 16:454,34359,454,73022,296,00017,229,00094,797,824
6Apr 26, 2026 16:454,34658,783,81318,256,00021,298,00094,793,728
7Apr 26, 2026 16:454,34961,278,14828,416,00011,163,00094,793,728
8Apr 26, 2026 16:454,36958,256,76921,867,00017,891,00094,785,536
9Apr 26, 2026 16:454,37759,611,55221,910,00017,926,00094,793,728