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 12, 2026 22:10Victor MerckléVictor MerckléScore: 2,672Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 12, 2026 22:162,66231,845,83615,574,0008,658,00092,745,728
2Jun 12, 2026 22:162,66331,904,02315,571,0008,667,00092,688,384
3Jun 12, 2026 22:162,66631,904,26715,594,0008,668,00092,770,304
4Jun 12, 2026 22:162,66731,786,00515,570,0008,708,00092,704,768
5Jun 12, 2026 22:162,67231,956,47215,591,0008,728,00092,708,864
6Jun 12, 2026 22:162,67931,883,84015,650,0008,736,00092,729,344
7Jun 12, 2026 22:162,68732,169,97815,666,0008,791,00092,708,864
8Jun 12, 2026 22:162,69032,034,62515,689,0008,793,00092,733,440
9Jun 12, 2026 22:162,69032,066,50715,688,0008,793,00092,717,056