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 19, 2026 13:16Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 05:23Tomislav Tunkovic13.23CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 05:54050,431,85736,680,0004,513,00051,662,848invalid character 'g' looking for beginning of valuestderr
2Sep 5, 2026 05:54050,305,20536,769,0004,461,00051,724,288invalid character 's' looking for beginning of valuestderr
3Sep 5, 2026 05:54050,305,44036,740,0004,472,00051,675,136invalid character 'h' looking for beginning of valuestderr
4Aug 19, 2026 13:222,48130,913,77414,066,0008,514,00092,745,728stderr
5Aug 19, 2026 13:222,48531,109,44414,056,0008,558,00092,737,536stderr
6Aug 19, 2026 13:222,48730,997,56214,133,0008,503,00092,704,768stderr
7Aug 19, 2026 13:222,48931,045,70714,061,0008,591,00092,778,496stderr
8Aug 19, 2026 13:222,49331,689,36814,183,0008,509,00092,745,728stderr
9Aug 19, 2026 13:222,49531,716,33814,137,0008,573,00092,762,112stderr
10Aug 19, 2026 13:222,49731,746,45614,175,0008,553,00092,762,112stderr
11Aug 19, 2026 13:222,50331,437,69614,082,0008,700,00092,770,304stderr
12Aug 19, 2026 13:222,51432,023,68114,109,0008,771,00092,762,112stderr