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 04:20Andrew EpsteinAndrew EpsteinScore: 2,552Success
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 04:412,52734,231,55314,278,0008,724,00092,737,536
2Nov 3, 2026 04:412,53733,999,09714,319,0008,771,00092,737,536
3Nov 3, 2026 04:412,54433,998,67314,380,0008,772,00092,692,480
4Nov 3, 2026 04:412,54834,503,31214,395,0008,796,00092,815,360
5Nov 3, 2026 04:412,55234,075,35514,354,0008,878,00092,700,672
6Nov 3, 2026 04:412,55934,681,96314,377,0008,913,00092,692,480
7Nov 3, 2026 04:412,56836,077,85914,499,0008,878,00092,729,344
8Nov 3, 2026 04:412,56934,215,49414,445,0008,935,00092,762,112
9Nov 3, 2026 04:412,57034,329,53414,536,0008,854,00092,721,152