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 23, 2026 22:51Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 09:46Victor Mercklé10.29CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 09:47011,488,63902,074,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 09:47011,535,38202,038,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 09:47011,518,11902,070,0002,121,728invalid character '<' after object key:value pair
4Apr 23, 2026 22:534,68058,768,04025,751,00016,837,00094,793,728
5Apr 23, 2026 22:534,69558,322,74627,824,00014,906,00094,797,824
6Apr 23, 2026 22:534,72358,686,72926,989,00015,993,00094,785,536
7Apr 23, 2026 22:534,72760,063,52524,011,00019,008,00094,781,440
8Apr 23, 2026 22:534,73059,799,55724,024,00019,019,00094,789,632
9Apr 23, 2026 22:534,74857,370,44827,132,00016,078,00094,789,632
10Apr 23, 2026 22:534,74857,844,20826,126,00017,082,00094,801,920
11Apr 23, 2026 22:534,76361,961,30126,209,00017,136,00094,789,632
12Apr 23, 2026 22:534,76859,985,70626,239,00017,156,00094,609,408