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 09:33Dominique GarmierDominique GarmierScore: 9,924Success
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 09:399,862120,395,73278,779,00010,969,00094,539,776
2Mar 17, 2026 09:329,885117,949,20881,957,0007,995,00094,793,728
3Mar 17, 2026 09:329,893112,637,18674,019,00016,004,00094,539,776
4Mar 17, 2026 09:399,905118,583,67477,119,00013,020,00094,564,352
5Mar 17, 2026 09:329,924113,757,11678,264,00012,040,00094,564,352
6Mar 17, 2026 09:339,927115,575,43476,284,00014,052,00094,539,776
7Mar 17, 2026 09:339,938114,494,93175,366,00015,073,00094,785,536
8Mar 17, 2026 09:3310,012113,825,90588,103,0003,003,00094,543,872
9Mar 17, 2026 09:3911,757131,087,39687,994,00018,998,00094,547,968