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 13:34janwwwjanwwwScore: 3,919Success
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 13:403,90944,811,93727,040,0008,535,00092,790,784
2Nov 5, 2026 13:403,91145,443,20127,257,0008,339,00092,753,920
3Nov 5, 2026 13:403,91245,353,81427,067,0008,540,00092,741,632
4Nov 5, 2026 13:403,91845,410,89227,081,0008,580,00092,766,208
5Nov 5, 2026 13:403,91945,385,23627,080,0008,584,00092,717,056
6Nov 5, 2026 13:403,91944,851,70327,092,0008,576,00092,749,824
7Nov 5, 2026 13:403,92144,917,51927,058,0008,624,00092,684,288
8Nov 5, 2026 13:403,92544,987,55727,076,0008,650,00092,676,096
9Nov 5, 2026 13:403,92745,491,17827,081,0008,657,00092,712,960