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 08:48limanjun99limanjun99Score: 137,897Success
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 08:50137,5671,283,724,1391,211,897,00039,963,00094,769,152
2Apr 21, 2026 08:50137,7281,274,311,2771,212,388,00040,945,00094,552,064
3Apr 21, 2026 08:50137,7371,282,591,0771,217,461,00035,954,00094,543,872
4Apr 21, 2026 08:50137,7671,279,633,0531,206,733,00046,950,00094,769,152
5Apr 21, 2026 08:50137,8971,278,628,2401,212,909,00041,962,00094,781,440
6Apr 21, 2026 08:50137,9171,280,435,6431,225,076,00029,977,00094,769,152
7Apr 21, 2026 08:50138,1611,287,611,6901,213,295,00043,974,00094,769,152
8Apr 21, 2026 08:50138,8151,288,610,8161,229,246,00033,979,00094,773,248
9Apr 21, 2026 08:50150,7911,397,631,9651,329,262,00042,943,00094,769,152