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 listMar 3, 2026 22:41olliecrowolliecrowScore: 16,030Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 3, 2026 22:4115,962171,821,158113,420,00031,837,00094,543,872
2Mar 3, 2026 22:4115,975168,538,471112,515,00032,858,00094,793,728
3Mar 3, 2026 22:4116,018168,429,806122,802,00022,962,00094,572,544
4Mar 3, 2026 22:4116,029172,688,044127,879,00017,983,00094,547,968
5Mar 3, 2026 22:4116,030171,024,928126,893,00018,984,00094,793,728
6Mar 3, 2026 22:4116,048174,127,657130,035,00016,004,00094,552,064
7Mar 3, 2026 22:4116,170171,612,761119,306,00027,838,00094,560,256
8Mar 3, 2026 22:4116,360173,547,261132,889,00015,986,00094,801,920
9Mar 3, 2026 22:4116,711178,325,193136,065,00016,007,00094,543,872