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 listAug 14, 2026 18:48marko1597marko1597Score: 47,686Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 18:5647,614443,469,550412,684,00020,606,00094,396,416stderr
2Aug 14, 2026 18:5647,632443,553,888412,727,00020,733,00094,396,416stderr
3Aug 14, 2026 18:5647,658443,722,208412,850,00020,839,00094,396,416stderr
4Aug 14, 2026 18:5647,681444,656,817412,871,00021,034,00094,396,416stderr
5Aug 14, 2026 18:5647,686443,999,128413,130,00020,813,00094,396,416stderr
6Aug 14, 2026 18:5647,706444,137,578413,381,00020,750,00094,396,416stderr
7Aug 14, 2026 18:5647,714444,924,219413,270,00020,933,00094,396,416stderr
8Aug 14, 2026 18:5647,720444,375,719413,394,00020,859,00094,396,416stderr
9Aug 14, 2026 18:5647,724445,058,505413,189,00021,102,00094,396,416stderr