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 10, 2026 08:31Victor MerckléVictor MerckléScore: 2,748Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 08:422,73032,438,95616,252,0008,599,00092,774,400
2Jun 10, 2026 08:422,73532,488,76216,380,0008,510,00092,758,016
3Jun 10, 2026 08:422,74332,609,87316,285,0008,685,00092,745,728
4Jun 10, 2026 08:422,74532,572,62116,414,0008,572,00092,721,152
5Jun 10, 2026 08:422,74832,484,52916,422,0008,588,00092,721,152
6Jun 10, 2026 08:422,74932,575,83616,332,0008,686,00092,774,400
7Jun 10, 2026 08:422,75732,627,94216,509,0008,581,00092,725,248
8Jun 10, 2026 08:422,76632,692,96016,290,0008,885,00092,758,016
9Jun 10, 2026 08:422,77132,745,05716,336,0008,882,00092,741,632