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 4, 2026 03:52olliecrowolliecrowScore: 9,443Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 03:529,418108,311,87868,761,00016,941,00094,572,544
2Mar 4, 2026 03:529,428112,057,23271,825,00013,966,00094,543,872
3Mar 4, 2026 03:529,430108,748,05368,847,00016,962,00094,552,064
4Mar 4, 2026 03:529,437108,719,22468,904,00016,976,00094,543,872
5Mar 4, 2026 03:529,443114,778,69365,946,00019,983,00094,547,968
6Mar 4, 2026 03:529,445113,494,71168,962,00016,990,00094,572,544
7Mar 4, 2026 03:529,493111,595,19672,321,00014,062,00094,556,160
8Mar 4, 2026 03:529,526111,792,19768,751,00017,935,00094,543,872
9Mar 4, 2026 03:529,527111,301,69666,769,00019,931,00094,568,448