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 15, 2026 07:20Tomislav TunkovicTomislav TunkovicScore: 4,747Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 07:264,71951,267,10318,362,00024,589,00094,400,512stderr
2Aug 15, 2026 07:264,71951,132,76118,430,00024,518,00094,400,512stderr
3Aug 15, 2026 07:264,74051,284,35818,401,00024,737,00094,400,512stderr
4Aug 15, 2026 07:264,74051,464,01218,578,00024,560,00094,400,512stderr
5Aug 15, 2026 07:264,74751,390,83818,451,00024,749,00094,400,512stderr
6Aug 15, 2026 07:264,76251,524,30018,487,00024,850,00094,400,512stderr
7Aug 15, 2026 07:264,76851,662,44618,520,00024,875,00094,400,512stderr
8Aug 15, 2026 07:264,77051,610,09818,446,00024,962,00094,400,512stderr
9Aug 15, 2026 07:264,77151,625,95718,480,00024,940,00094,400,512stderr