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 21:15Charles CabergsCharles CabergsScore: 7,640Success
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 21:177,58286,045,11648,998,00019,999,00094,597,120
2Apr 21, 2026 21:177,60287,728,96950,133,00019,050,00094,797,824
3Apr 21, 2026 21:177,60587,317,77551,153,00018,054,00094,609,408
4Apr 21, 2026 21:177,62486,762,06052,288,00017,094,00094,789,632
5Apr 21, 2026 21:177,64086,432,33651,649,00017,878,00094,593,024
6Apr 21, 2026 21:177,64389,939,70452,661,00016,891,00094,785,536
7Apr 21, 2026 21:177,64388,795,89451,672,00017,886,00094,793,728
8Apr 21, 2026 21:177,66284,961,67149,807,00019,923,00094,793,728
9Apr 21, 2026 21:177,68088,601,23151,923,00017,973,00094,797,824