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 19, 2026 02:22Dominique GarmierDominique GarmierScore: 8,063Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 14:278,04398,575,77954,143,00019,050,00094,564,352
2Mar 17, 2026 14:278,04898,311,88056,182,00017,055,00094,564,352
3Mar 20, 2026 09:308,050104,868,07456,197,00017,060,00094,564,352
4Mar 17, 2026 14:278,062102,541,87457,287,00016,080,00094,547,968
5Mar 20, 2026 09:308,06399,790,12158,294,00015,076,00094,564,352
6Mar 19, 2026 02:228,066104,242,91860,329,00013,071,00094,797,824
7Mar 20, 2026 09:308,07799,244,63356,617,00016,885,00094,564,352
8Mar 19, 2026 02:228,09097,167,02853,724,00019,898,00094,629,888
9Mar 19, 2026 02:228,106101,990,57855,824,00017,943,00094,564,352