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 listAug 24, 2026 00:51Andrew EpsteinAndrew EpsteinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:01Tomislav Tunkovic27.91CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:02011,293,4001,393,000020,480Exit with code 1:
2Aug 24, 2026 00:5628,375268,268,349241,903,00016,318,00094,392,320
3Aug 24, 2026 00:5628,399268,457,701242,090,00016,346,00094,392,320
4Aug 24, 2026 00:5628,399268,369,575242,053,00016,385,00094,392,320
5Aug 24, 2026 00:5628,399268,436,861242,061,00016,373,00094,392,320
6Aug 24, 2026 00:5628,402268,520,766241,920,00016,547,00094,392,320
7Aug 24, 2026 00:5628,428268,717,764242,299,00016,403,00094,392,320
8Aug 24, 2026 00:5628,433269,316,736241,199,00017,543,00094,392,320
9Aug 24, 2026 00:5628,438269,562,869242,214,00016,576,00094,392,320
10Aug 24, 2026 00:5628,478269,385,803241,716,00017,435,00094,392,320