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 01:37Andrew EpsteinAndrew EpsteinScore: 3,197Success
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 01:533,17939,719,26720,506,0008,424,00092,762,112
2Nov 3, 2026 01:533,18139,771,13720,502,0008,447,00092,729,344
3Nov 3, 2026 01:533,18339,888,66420,539,0008,435,00092,684,288
4Nov 3, 2026 01:533,19639,904,65420,556,0008,534,00092,778,496
5Nov 3, 2026 01:533,19740,419,26320,632,0008,468,00092,758,016
6Nov 3, 2026 01:533,20040,523,44120,620,0008,506,00092,749,824
7Nov 3, 2026 01:533,20440,099,96820,602,0008,556,00092,778,496
8Nov 3, 2026 01:533,20440,081,55120,592,0008,566,00092,782,592
9Nov 3, 2026 01:533,22240,710,62720,704,0008,622,00092,692,480