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:15Victor MerckléVictor MerckléScore: 2,938Success
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:202,91835,626,67717,912,0008,646,00092,741,632
2Jun 5, 2026 16:202,92535,648,58817,961,0008,664,00092,770,304
3Jun 5, 2026 16:202,92935,729,75517,969,0008,693,00092,729,344
4Jun 5, 2026 16:202,93735,714,37218,175,0008,558,00092,733,440
5Jun 5, 2026 16:202,93835,734,52418,192,0008,548,00092,766,208
6Jun 5, 2026 16:202,94235,844,41718,026,0008,755,00092,700,672
7Jun 5, 2026 16:202,94835,807,69318,181,0008,650,00092,798,976
8Jun 5, 2026 16:202,94935,930,45918,225,0008,612,00092,733,440
9Jun 5, 2026 16:202,95635,979,25718,228,0008,674,00092,733,440