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 4, 2026 05:38olliecrowolliecrowScore: 8,290Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 05:388,23994,627,24358,977,00015,994,00094,572,544
2Mar 4, 2026 05:168,259100,169,12958,125,00017,036,00094,568,448
3Mar 4, 2026 05:388,26695,849,57460,179,00015,044,00094,666,752
4Mar 4, 2026 05:388,27499,482,51659,232,00016,063,00094,552,064
5Mar 4, 2026 05:388,280104,996,90158,267,00017,078,00094,543,872
6Mar 4, 2026 05:168,286102,558,07659,315,00016,085,00094,560,256
7Mar 4, 2026 05:388,29099,071,25959,555,00015,881,00094,552,064
8Mar 4, 2026 05:388,295106,398,21059,384,00016,104,00094,552,064
9Mar 4, 2026 05:388,296110,482,93060,596,00014,900,00094,556,160
10Mar 4, 2026 05:388,317102,724,15358,759,00016,930,00094,793,728
11Mar 4, 2026 05:168,345110,441,49757,957,00017,986,00094,552,064
12Mar 4, 2026 05:388,562105,014,33357,935,00019,977,00094,556,160