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 22:40marko1597marko1597Score: 34,822Success
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 23:0734,799325,153,332308,478,0008,196,00092,688,384stderr
2Aug 15, 2026 23:0734,799325,095,844308,486,0008,190,00092,749,824stderr
3Aug 15, 2026 23:0734,811325,342,457308,536,0008,245,00092,680,192stderr
4Aug 15, 2026 23:0734,817325,960,217308,602,0008,233,00092,704,768stderr
5Aug 15, 2026 23:0734,822325,373,184308,675,0008,207,00092,758,016stderr
6Aug 15, 2026 23:0734,852325,662,126308,861,0008,297,00092,758,016stderr
7Aug 15, 2026 23:0734,857325,635,485308,930,0008,271,00092,721,152stderr
8Aug 15, 2026 23:0734,868325,849,935309,082,0008,224,00092,811,264stderr
9Aug 15, 2026 23:0734,892325,977,443309,187,0008,333,00092,794,880stderr