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 listNov 5, 2026 04:51Andrew EpsteinAndrew EpsteinScore: 2,468Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 05:052,44831,484,77613,593,0008,684,00092,807,168
2Nov 5, 2026 05:052,46031,768,60213,774,0008,613,00092,745,728
3Nov 5, 2026 05:052,46431,631,50113,826,0008,599,00092,815,360
4Nov 5, 2026 05:052,46431,606,73913,748,0008,680,00092,684,288
5Nov 5, 2026 05:052,46831,641,21113,857,0008,607,00092,712,960
6Nov 5, 2026 05:052,47031,954,71213,764,0008,719,00092,737,536
7Nov 5, 2026 05:052,47431,760,14713,887,0008,635,00092,717,056
8Nov 5, 2026 05:052,47931,662,28913,876,0008,685,00092,696,576
9Nov 5, 2026 05:052,48931,922,99813,821,0008,833,00092,721,152