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 14:23Tomislav TunkovicTomislav TunkovicScore: 6,074Success
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 14:356,02863,167,05923,678,00031,177,00094,396,416
2Aug 14, 2026 14:356,06363,392,89623,968,00031,211,00094,396,416
3Aug 14, 2026 14:356,06563,363,15823,713,00031,482,00094,396,416
4Aug 14, 2026 14:356,07363,588,25824,023,00031,247,00094,396,416
5Aug 14, 2026 14:356,07463,407,42623,961,00031,315,00094,396,416
6Aug 14, 2026 14:356,08063,529,21924,025,00031,308,00094,396,416
7Aug 14, 2026 14:356,08563,581,39624,041,00031,340,00094,396,416
8Aug 14, 2026 14:356,09963,726,48823,949,00031,560,00094,396,416
9Aug 14, 2026 14:356,10363,778,13124,091,00031,448,00094,396,416