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 10:16limanjun99limanjun99Score: 4,791Success
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 10:184,75467,530,78427,166,00016,098,00092,925,952
2Apr 21, 2026 10:184,75864,618,44726,183,00017,119,00093,159,424
3Apr 21, 2026 10:184,78270,582,70226,705,00016,814,00092,889,088
4Apr 21, 2026 10:184,79070,515,91226,752,00016,844,00092,880,896
5Apr 21, 2026 10:184,79173,537,92126,757,00016,847,00093,114,368
6Apr 21, 2026 10:184,79469,598,65826,772,00016,856,00093,102,080
7Apr 21, 2026 10:184,79870,477,95826,794,00016,870,00093,118,464
8Apr 21, 2026 10:184,82069,606,54426,919,00016,949,00093,106,176
9Apr 21, 2026 10:184,82769,429,46626,956,00016,972,00092,954,624