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 3, 2026 23:51olliecrowolliecrowScore: 13,404Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 3, 2026 23:5113,357147,732,704101,626,00019,926,00094,552,064
2Mar 3, 2026 23:5113,379147,230,429103,783,00017,962,00094,547,968
3Mar 3, 2026 23:5113,400150,088,478105,952,00015,992,00094,572,544
4Mar 3, 2026 23:5113,403145,730,889101,970,00019,994,00094,547,968
5Mar 3, 2026 23:5113,404144,761,050101,984,00019,996,00094,543,872
6Mar 3, 2026 23:5113,405147,273,90499,988,00021,997,00094,547,968
7Mar 3, 2026 23:5113,418144,314,838100,085,00022,018,00094,793,728
8Mar 3, 2026 23:5113,452150,081,719105,492,00016,918,00094,564,352
9Mar 3, 2026 23:5113,463144,821,938106,578,00015,937,00094,572,544