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 listJul 3, 2026 15:55A_ShamanA_ShamanScore: 23,651Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 3, 2026 16:0323,499223,459,669163,376,00050,472,000171,991,040
2Jul 3, 2026 16:0323,537224,254,755163,669,00050,521,000169,893,888
3Jul 3, 2026 16:0323,582224,616,624163,601,00051,002,000169,893,888
4Jul 3, 2026 16:0323,614224,877,408163,828,00051,060,000169,893,888
5Jul 3, 2026 16:0323,651225,320,674164,514,00050,711,000169,893,888
6Jul 3, 2026 16:0323,664225,330,621163,997,00051,346,000169,893,888
7Jul 3, 2026 16:0323,689225,186,069163,948,00051,626,000169,893,888
8Jul 3, 2026 16:0323,711225,776,299164,551,00051,221,000171,991,040
9Jul 3, 2026 16:0323,712228,188,884164,714,00051,068,000169,893,888