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 listJan 18, 2026 06:45Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 10:47Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 10:49013,269,5021,556,0002,359,0004,214,784invalid character '\n' in string literal
2Jul 6, 2026 10:49013,164,5601,605,0002,120,0004,214,784invalid character '\n' in string literal
3Jul 6, 2026 10:49014,780,8091,567,0002,347,0004,214,784invalid character '\n' in string literal
4Jan 18, 2026 06:455,20069,997,54533,227,00014,096,00094,552,064
5Jan 18, 2026 06:455,20170,557,65734,240,00013,091,00094,552,064
6Jan 18, 2026 06:455,20271,081,76732,230,00015,107,00094,674,944
7Jan 18, 2026 06:455,21773,375,11329,295,00018,183,00094,552,064
8Jan 18, 2026 06:455,22280,937,74229,322,00018,200,00094,666,752
9Jan 18, 2026 06:455,22371,971,15423,764,00023,764,00094,789,632
10Jan 18, 2026 06:455,23370,798,96525,792,00021,824,00094,552,064
11Jan 18, 2026 06:455,23778,605,38225,816,00021,844,00094,670,848
12Jan 18, 2026 06:455,24475,625,31225,849,00021,872,00094,666,752
13Jan 18, 2026 06:455,25675,661,42128,895,00018,931,00094,679,040
14Jan 18, 2026 06:455,26676,172,09824,957,00022,960,00094,679,040
15Jan 18, 2026 06:455,26972,772,42825,973,00021,977,00094,679,040