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 listAug 16, 2026 08:11marko1597marko1597Score: 3,270Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 08:453,25937,981,28121,351,0008,312,00092,758,016stderr
2Aug 16, 2026 08:453,26038,006,61821,361,0008,311,00092,827,648stderr
3Aug 16, 2026 08:453,26138,017,82121,392,0008,289,00092,712,960stderr
4Aug 16, 2026 08:453,26738,077,72821,393,0008,343,00092,774,400stderr
5Aug 16, 2026 08:453,27038,102,24221,423,0008,340,00092,782,592stderr
6Aug 16, 2026 08:453,27138,119,39721,431,0008,336,00092,778,496stderr
7Aug 16, 2026 08:453,28438,242,82521,475,0008,415,00092,745,728stderr
8Aug 16, 2026 08:453,28838,280,51721,502,0008,426,00092,778,496stderr
9Aug 16, 2026 08:453,30638,405,34321,596,0008,497,00092,794,880stderr