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 21, 2026 15:14limanjun99limanjun99Error
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 5, 2026 23:56Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 5, 2026 23:57036,498,20817,870,0008,520,00094,392,320invalid character '<' after object key:value pair
2Jul 5, 2026 23:57035,984,98117,955,0008,476,00094,392,320invalid character '<' after object key:value pair
3Jul 5, 2026 23:57036,254,53218,051,0008,575,00094,392,320invalid character '<' after object key:value pair
4Apr 21, 2026 15:173,09550,306,60319,117,0009,055,00093,151,232
5Apr 21, 2026 15:173,09844,103,90319,133,0009,063,00092,999,680
6Apr 21, 2026 15:173,10944,896,14418,192,00010,106,00093,011,968
7Apr 21, 2026 15:173,11047,634,82419,205,0009,097,00092,925,952
8Apr 21, 2026 15:173,11643,347,49519,244,0009,115,00093,229,056
9Apr 21, 2026 15:173,12442,989,00818,279,00010,155,00093,122,560
10Apr 21, 2026 15:173,13049,980,34519,329,0009,155,00093,147,136
11Apr 21, 2026 15:173,13445,103,88319,354,0009,168,00093,003,776
12Apr 21, 2026 15:173,13751,466,09918,355,00010,197,00093,130,752