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 listApr 28, 2026 21:45Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 08:23Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 08:25011,776,27402,027,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 08:25011,857,52802,152,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 08:25011,495,21902,015,0002,121,728invalid character '<' after object key:value pair
4Apr 28, 2026 21:474,03754,401,99217,872,00018,865,00094,797,824
5Apr 28, 2026 21:474,03856,516,33018,873,00017,879,00094,609,408
6Apr 28, 2026 21:474,04059,832,53618,882,00017,889,00094,785,536
7Apr 28, 2026 21:474,08651,524,34119,098,00018,093,00094,605,312
8Apr 28, 2026 21:474,09350,546,19420,138,00017,117,00094,789,632
9Apr 28, 2026 21:474,09356,716,69219,131,00018,124,00094,789,632
10Apr 28, 2026 21:474,09657,939,62018,134,00019,142,00094,806,016
11Apr 28, 2026 21:474,13554,994,85519,325,00018,307,00094,785,536
12Apr 28, 2026 21:474,18054,407,84419,022,00019,022,00094,789,632