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 listApr 27, 2026 01:44Charles CabergsCharles CabergsScore: 4,311Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 27, 2026 01:464,28654,864,79722,003,00017,002,00094,797,824
2Apr 27, 2026 01:464,29060,506,11121,021,00018,018,00094,789,632
3Apr 27, 2026 01:464,30057,433,01518,064,00021,075,00094,797,824
4Apr 27, 2026 01:464,30355,637,94719,080,00020,085,00094,793,728
5Apr 27, 2026 01:464,31158,371,67023,137,00016,095,00094,793,728
6Apr 27, 2026 01:464,32156,628,93422,182,00017,140,00094,806,016
7Apr 27, 2026 01:464,32659,132,72722,211,00017,163,00094,801,920
8Apr 27, 2026 01:464,36357,043,25519,856,00019,856,00094,609,408
9Apr 27, 2026 01:464,36762,538,54022,851,00016,890,00094,797,824