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 listSep 14, 2026 01:34Andrew EpsteinAndrew EpsteinScore: 9,474Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 01:409,22494,323,80555,538,00028,406,00092,909,568
2Sep 14, 2026 01:409,37495,704,80555,451,00029,858,00092,901,376
3Sep 14, 2026 01:409,39896,185,70355,586,00029,943,00092,958,720
4Sep 14, 2026 01:409,44596,285,66155,703,00030,250,00092,938,240
5Sep 14, 2026 01:409,47496,523,00655,801,00030,418,00092,942,336
6Sep 14, 2026 01:409,48796,574,75256,280,00030,057,00092,913,664
7Sep 14, 2026 01:409,48896,655,39955,791,00030,551,00092,979,200
8Sep 14, 2026 01:409,53797,078,34256,284,00030,503,00092,942,336
9Sep 14, 2026 01:409,58698,328,79356,439,00030,802,00092,893,184