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 21, 2026 16:04Charles CabergsCharles CabergsScore: 10,895Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 16:0710,857115,255,01174,852,00023,952,00094,785,536
2Apr 21, 2026 16:0710,875118,594,85675,977,00022,993,00094,781,440
3Apr 21, 2026 16:0710,881119,211,38177,016,00022,004,00094,785,536
4Apr 21, 2026 16:0710,895114,785,64578,116,00021,031,00094,785,536
5Apr 21, 2026 16:0710,895116,468,26678,120,00021,032,00094,605,312
6Apr 21, 2026 16:0710,898115,652,10075,137,00024,043,00094,601,216
7Apr 21, 2026 16:0710,899119,021,79774,139,00025,047,00094,777,344
8Apr 21, 2026 16:0710,948118,066,27778,707,00020,922,00094,609,408
9Apr 21, 2026 16:0710,950119,133,47079,720,00019,930,00094,793,728