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 23, 2026 02:11olliecrowolliecrowScore: 7,525Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2026 02:157,46776,567,84551,965,00015,989,00094,654,464
2Apr 23, 2026 02:157,46876,424,15451,972,00015,991,00094,654,464
3Apr 23, 2026 02:157,48776,637,29749,096,00019,037,00094,654,464
4Apr 23, 2026 02:157,50984,838,41949,244,00019,094,00094,851,072
5Apr 23, 2026 02:157,52576,768,13650,357,00018,128,00094,654,464
6Apr 23, 2026 02:157,57976,306,56750,979,00017,992,00094,633,984
7Apr 23, 2026 02:157,58476,593,78249,011,00020,004,00094,654,464
8Apr 23, 2026 02:157,61076,912,29550,187,00019,071,00094,633,984
9Apr 23, 2026 02:157,66978,304,02651,848,00017,947,00094,629,888