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 listMar 17, 2026 10:15Dominique GarmierDominique GarmierScore: 7,615Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 10:157,58293,716,68349,997,00018,998,00094,793,728
2Mar 17, 2026 10:157,60090,288,89651,116,00018,041,00094,560,256
3Mar 17, 2026 10:157,60690,927,33052,163,00017,053,00094,547,968
4Mar 17, 2026 10:157,61295,425,95651,200,00018,070,00094,564,352
5Mar 17, 2026 10:157,61592,682,32952,226,00017,074,00094,720,000
6Mar 17, 2026 10:157,629100,194,09049,299,00020,122,00094,564,352
7Mar 17, 2026 10:157,661102,827,06850,791,00018,922,00094,539,776
8Mar 17, 2026 10:157,671100,140,90050,857,00018,946,00094,543,872
9Mar 17, 2026 10:158,190100,320,18756,643,00017,887,00094,564,352