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 12, 2026 17:06Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 22:37Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 22:51020,621,4688,587,0003,480,00041,811,968invalid character 's' looking for beginning of value
2Sep 4, 2026 22:51020,705,3098,727,0003,551,00041,816,064invalid character 's' looking for beginning of value
3Sep 4, 2026 22:51020,614,3198,036,0004,222,00041,807,872invalid character 's' looking for beginning of value
4Jun 12, 2026 17:122,66131,682,25815,555,0008,664,00092,729,344
5Jun 12, 2026 17:122,66931,805,54415,577,0008,714,00092,737,536
6Jun 12, 2026 17:122,67131,765,97715,573,0008,737,00092,758,016
7Jun 12, 2026 17:122,67932,011,49615,642,0008,737,00092,704,768
8Jun 12, 2026 17:122,68132,065,83315,675,0008,723,00092,733,440
9Jun 12, 2026 17:122,69132,496,02315,693,0008,803,00092,753,920
10Jun 12, 2026 17:122,69332,095,58715,620,0008,892,00092,721,152
11Jun 12, 2026 17:122,69732,587,04715,690,0008,861,00092,741,632
12Jun 12, 2026 17:122,69933,653,04815,693,0008,873,00092,717,056