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 listNov 5, 2026 05:24Andrew EpsteinAndrew EpsteinScore: 2,348Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 06:222,33430,282,56312,871,0008,373,00092,729,344
2Nov 5, 2026 06:222,33930,360,53112,877,0008,409,00092,712,960
3Nov 5, 2026 06:222,34030,391,06512,845,0008,455,00092,770,304
4Nov 5, 2026 06:222,34430,451,42012,907,0008,430,00092,725,248
5Nov 5, 2026 06:222,34830,235,86712,849,0008,524,00092,725,248
6Nov 5, 2026 06:222,35430,477,24212,919,0008,507,00092,774,400
7Nov 5, 2026 06:222,35730,531,49512,905,0008,550,00092,712,960
8Nov 5, 2026 06:222,36130,580,46713,037,0008,456,00092,753,920
9Nov 5, 2026 06:222,36330,591,37912,983,0008,523,00092,725,248