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 16, 2026 07:21marko1597marko1597Score: 3,467Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 07:403,44139,644,11923,031,0008,286,00092,770,304stderr
2Aug 16, 2026 07:403,45839,842,49823,189,0008,282,00092,708,864stderr
3Aug 16, 2026 07:403,45939,952,47323,126,0008,355,00092,712,960stderr
4Aug 16, 2026 07:403,46239,989,44223,156,0008,352,00092,790,784stderr
5Aug 16, 2026 07:403,46740,649,98223,192,0008,364,00092,721,152stderr
6Aug 16, 2026 07:403,47440,041,10723,180,0008,439,00092,745,728stderr
7Aug 16, 2026 07:403,47440,683,04623,213,0008,403,00092,786,688stderr
8Aug 16, 2026 07:403,48240,127,71823,219,0008,469,00092,753,920stderr
9Aug 16, 2026 07:403,48640,092,82623,257,0008,470,00092,790,784stderr