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 00:54Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 08:56Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 08:57011,369,78102,009,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 08:57011,582,78302,165,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 08:57011,565,43702,140,0002,121,728invalid character '<' after object key:value pair
4Apr 28, 2026 00:564,16859,581,71718,966,00018,966,00094,793,728
5Apr 28, 2026 00:564,16852,414,90319,967,00017,970,00094,625,792
6Apr 28, 2026 00:564,19454,526,09919,087,00019,087,00094,801,920
7Apr 28, 2026 00:564,19554,721,15518,083,00020,092,00094,613,504
8Apr 28, 2026 00:564,19953,465,42918,104,00020,115,00094,605,312
9Apr 28, 2026 00:564,20055,308,80220,120,00018,108,00094,789,632
10Apr 28, 2026 00:564,21956,746,63922,829,00015,565,00094,789,632
11Apr 28, 2026 00:564,22654,786,92323,277,00015,180,00094,617,600
12Apr 28, 2026 00:564,24557,473,39723,384,00015,250,00094,793,728