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 21, 2026 23:23olliecrowolliecrowScore: 4,899Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 23:254,86159,630,55128,153,00016,087,00094,621,696
2Apr 21, 2026 23:254,88164,113,70826,251,00018,174,00094,638,080
3Apr 21, 2026 23:254,89461,552,99528,703,00015,836,00094,642,176
4Apr 21, 2026 23:254,89763,720,01926,337,00018,233,00094,613,504
5Apr 21, 2026 23:254,89964,265,31128,731,00015,851,00094,621,696
6Apr 21, 2026 23:254,90059,248,35624,775,00019,820,00094,629,888
7Apr 21, 2026 23:254,90163,114,73825,772,00018,833,00094,613,504
8Apr 21, 2026 23:254,91659,408,87229,829,00014,914,00094,625,792
9Apr 21, 2026 23:254,91660,389,78429,827,00014,913,00094,633,984