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 listJun 11, 2026 17:41Victor MerckléVictor MerckléScore: 2,721Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 17:472,70533,662,04715,913,0008,704,00092,696,576
2Jun 11, 2026 17:472,70933,743,51015,922,0008,734,00092,803,072
3Jun 11, 2026 17:472,71133,670,10415,741,0008,938,00092,708,864
4Jun 11, 2026 17:472,71933,765,74815,992,0008,759,00092,815,360
5Jun 11, 2026 17:472,72133,818,09216,011,0008,753,00092,692,480
6Jun 11, 2026 17:472,72833,884,85116,014,0008,815,00092,762,112
7Jun 11, 2026 17:472,73233,915,80016,035,0008,833,00092,778,496
8Jun 11, 2026 17:472,73933,985,23216,039,0008,886,00092,794,880
9Jun 11, 2026 17:472,74134,017,17816,081,0008,864,00092,741,632