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 05:24Andrew EpsteinAndrew EpsteinScore: 2,355Success
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 06:142,33630,577,56312,817,0008,444,00092,696,576
2Nov 5, 2026 06:142,33830,469,44612,682,0008,596,00092,770,304
3Nov 5, 2026 06:142,35030,736,90112,998,0008,389,00092,774,400
4Nov 5, 2026 06:142,35430,786,54012,917,0008,512,00092,712,960
5Nov 5, 2026 06:142,35530,805,94413,012,0008,420,00092,762,112
6Nov 5, 2026 06:142,36030,811,55913,093,0008,392,00092,745,728
7Nov 5, 2026 06:142,36130,790,16013,034,0008,455,00092,803,072
8Nov 5, 2026 06:142,37330,889,87713,046,0008,553,00092,737,536
9Nov 5, 2026 06:142,38330,975,65113,154,0008,534,00092,758,016