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 listApr 22, 2026 08:58olliecrowolliecrowScore: 4,748Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 09:004,72658,500,74027,005,00016,003,00094,629,888
2Apr 22, 2026 09:004,73461,541,76227,051,00016,030,00094,629,888
3Apr 22, 2026 09:004,74058,959,96026,085,00017,055,00094,629,888
4Apr 22, 2026 09:004,74663,168,06125,111,00018,080,00094,613,504
5Apr 22, 2026 09:004,74862,339,67727,132,00016,078,00094,629,888
6Apr 22, 2026 09:004,75164,511,39827,153,00016,090,00094,629,888
7Apr 22, 2026 09:004,76062,671,99127,203,00016,120,00094,609,408
8Apr 22, 2026 09:004,76260,156,17927,213,00016,126,00094,617,600
9Apr 22, 2026 09:004,76364,594,48828,225,00015,120,00094,638,080