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 listSep 15, 2026 00:54Josu San MartinJosu San MartinScore: 3,975Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 01:023,94846,108,77118,793,00017,140,00094,392,320
2Sep 15, 2026 01:023,95046,078,81518,858,00017,089,00094,392,320
3Sep 15, 2026 01:023,96946,316,94018,770,00017,353,00094,392,320
4Sep 15, 2026 01:023,97446,328,09118,797,00017,370,00094,392,320
5Sep 15, 2026 01:023,97546,314,12818,784,00017,396,00094,392,320
6Sep 15, 2026 01:023,97846,361,26418,905,00017,300,00094,392,320
7Sep 15, 2026 01:023,98146,390,99618,746,00017,483,00094,392,320
8Sep 15, 2026 01:023,99046,500,53118,883,00017,427,00094,392,320
9Sep 15, 2026 01:024,00146,486,15918,924,00017,492,00094,392,320