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 3, 2026 07:59Andrew EpsteinAndrew EpsteinScore: 2,444Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 08:112,42032,221,40913,536,0008,495,00092,798,976
2Nov 3, 2026 08:112,42431,395,86413,417,0008,642,00092,700,672
3Nov 3, 2026 08:112,42431,321,90213,515,0008,547,00092,700,672
4Nov 3, 2026 08:112,43731,945,51513,634,0008,546,00092,762,112
5Nov 3, 2026 08:112,44431,600,54413,676,0008,567,00092,798,976
6Nov 3, 2026 08:112,44531,651,17713,642,0008,615,00092,758,016
7Nov 3, 2026 08:112,45032,069,19613,702,0008,600,00092,790,784
8Nov 3, 2026 08:112,45631,644,34613,726,0008,631,00092,741,632
9Nov 3, 2026 08:112,48232,178,20413,893,0008,700,00092,823,552