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 listJun 8, 2026 04:35Victor MerckléVictor MerckléScore: 2,736Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 8, 2026 04:422,72233,863,48315,947,0008,825,00092,741,632
2Jun 8, 2026 04:422,73033,878,73916,009,0008,841,00092,741,632
3Jun 8, 2026 04:422,73433,897,15416,039,0008,842,00092,680,192
4Jun 8, 2026 04:422,73533,985,67016,455,0008,441,00092,753,920
5Jun 8, 2026 04:422,73634,014,86316,205,0008,701,00092,758,016
6Jun 8, 2026 04:422,74033,987,57816,198,0008,741,00092,807,168
7Jun 8, 2026 04:422,74934,096,95116,224,0008,795,00092,717,056
8Jun 8, 2026 04:422,75434,226,32316,247,0008,823,00092,778,496
9Jun 8, 2026 04:422,75734,161,39216,264,0008,830,00092,725,248