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 listJun 11, 2026 17:29Victor MerckléVictor MerckléScore: 2,748Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 17:342,74234,355,86416,204,0008,754,00092,811,264
2Jun 11, 2026 17:342,74333,994,83416,221,0008,743,00092,737,536
3Jun 11, 2026 17:342,74433,998,29116,237,0008,740,00092,725,248
4Jun 11, 2026 17:342,74534,498,48616,226,0008,761,00092,667,904
5Jun 11, 2026 17:342,74834,031,31716,209,0008,805,00092,729,344
6Jun 11, 2026 17:342,74933,955,83116,233,0008,784,00092,721,152
7Jun 11, 2026 17:342,76334,146,87516,290,0008,858,00092,737,536
8Jun 11, 2026 17:342,76334,091,73816,253,0008,895,00092,798,976
9Jun 11, 2026 17:342,76534,335,93916,298,0008,864,00092,717,056