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 listAug 19, 2026 16:31Victor MerckléVictor MerckléScore: 2,426Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 16:402,41731,102,34413,503,0008,496,00092,741,632stderr
2Aug 19, 2026 16:402,41931,045,84013,515,0008,504,00092,774,400stderr
3Aug 19, 2026 16:402,42331,096,77813,509,0008,543,00092,704,768stderr
4Aug 19, 2026 16:402,42431,133,80313,507,0008,555,00092,819,456stderr
5Aug 19, 2026 16:402,42630,362,51213,545,0008,533,00092,762,112stderr
6Aug 19, 2026 16:402,42631,139,42813,528,0008,549,00092,770,304stderr
7Aug 19, 2026 16:402,43230,318,95813,539,0008,595,00092,749,824stderr
8Aug 19, 2026 16:402,43731,146,51213,531,0008,647,00092,774,400stderr
9Aug 19, 2026 16:402,43931,242,38813,556,0008,640,00092,766,208stderr