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 listJun 5, 2026 16:05Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 21:54Tomislav Tunkovic11.89CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 22:04022,441,9448,123,0004,278,00041,885,696invalid character 's' looking for beginning of value
2Sep 4, 2026 22:04023,724,4868,047,0004,318,00041,893,888invalid character 's' looking for beginning of value
3Sep 4, 2026 22:04023,015,6078,057,0004,355,00041,873,408invalid character 's' looking for beginning of value
4Jun 5, 2026 16:103,01336,493,86118,752,0008,675,00092,778,496
5Jun 5, 2026 16:103,01736,504,53918,948,0008,508,00092,741,632
6Jun 5, 2026 16:103,01936,570,30418,853,0008,624,00092,786,688
7Jun 5, 2026 16:103,02636,567,07018,915,0008,628,00092,749,824
8Jun 5, 2026 16:103,02736,694,06518,863,0008,691,00092,725,248
9Jun 5, 2026 16:103,02936,718,84918,902,0008,664,00092,737,536
10Jun 5, 2026 16:103,02936,575,17218,782,0008,787,00092,786,688
11Jun 5, 2026 16:103,02936,573,61318,880,0008,689,00092,737,536
12Jun 5, 2026 16:103,04436,787,11918,928,0008,781,00092,778,496