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 5, 2026 16:22Victor MerckléVictor MerckléScore: 2,979Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 16:272,97136,102,36818,359,0008,686,00092,745,728
2Jun 5, 2026 16:272,97536,159,71718,355,0008,719,00092,704,768
3Jun 5, 2026 16:272,97536,094,91618,548,0008,525,00092,770,304
4Jun 5, 2026 16:272,97936,242,38818,467,0008,650,00092,733,440
5Jun 5, 2026 16:272,97936,180,02918,383,0008,734,00092,733,440
6Jun 5, 2026 16:272,98136,205,79318,560,0008,574,00092,733,440
7Jun 5, 2026 16:272,98236,276,94318,551,0008,590,00092,708,864
8Jun 5, 2026 16:272,98636,225,43218,476,0008,702,00092,680,192
9Jun 5, 2026 16:272,99636,359,20818,601,0008,670,00092,782,592