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:37Tomislav TunkovicTomislav TunkovicScore: 6,179Success
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 15:206,15164,221,10024,771,00031,211,00094,396,416
2Aug 14, 2026 15:206,16064,231,38924,912,00031,151,00094,396,416
3Aug 14, 2026 15:206,17164,579,13324,854,00031,303,00094,396,416
4Aug 14, 2026 15:206,17664,424,69924,888,00031,321,00094,396,416
5Aug 14, 2026 15:206,17965,865,32924,881,00031,353,00094,396,416
6Aug 14, 2026 15:206,18864,466,79024,923,00031,391,00094,396,416
7Aug 14, 2026 15:206,19064,532,00724,810,00031,525,00094,396,416
8Aug 14, 2026 15:206,21264,686,94424,989,00031,545,00094,396,416
9Aug 14, 2026 15:206,21564,806,50525,020,00031,539,00094,396,416