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 01:59olliecrowolliecrowScore: 11,587Success
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 01:5911,523126,932,02785,885,00018,974,00094,552,064
2Mar 4, 2026 01:5911,547131,099,80987,068,00018,014,00094,547,968
3Mar 4, 2026 01:5911,576129,818,57691,297,00014,045,00094,801,920
4Mar 4, 2026 01:5911,587132,279,98090,377,00015,062,00094,560,256
5Mar 4, 2026 01:5911,587132,061,27089,376,00016,067,00094,572,544
6Mar 4, 2026 01:5911,592130,390,07284,389,00021,097,00094,801,920
7Mar 4, 2026 01:5911,593131,921,31991,432,00014,066,00094,543,872
8Mar 4, 2026 01:5911,639129,977,71287,933,00017,986,00094,556,160
9Mar 4, 2026 01:5911,711135,771,09991,490,00015,080,00094,572,544