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 listMar 10, 2026 20:22Josu San MartinJosu San MartinScore: 3,965Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 20:223,94562,852,93417,950,00017,950,00094,552,064
2Mar 10, 2026 20:223,94659,838,69218,950,00016,955,00094,552,064
3Mar 10, 2026 20:223,95359,072,88915,989,00019,986,00094,552,064
4Mar 10, 2026 20:223,96164,203,86617,023,00019,025,00094,552,064
5Mar 10, 2026 20:223,96558,800,03918,042,00018,042,00094,552,064
6Mar 10, 2026 20:223,99059,708,40320,173,00016,139,00094,552,064
7Mar 10, 2026 20:223,99164,155,27621,188,00015,134,00094,679,040
8Mar 10, 2026 20:224,02062,346,25718,290,00018,290,00094,552,064
9Mar 10, 2026 20:224,37864,863,05119,918,00019,918,00094,674,944