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 listJul 6, 2026 21:15Josu San MartinJosu San MartinScore: 4,108Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 21:224,06147,143,35420,014,00016,949,00094,396,416
2Jul 6, 2026 21:224,08546,604,14620,131,00017,044,00094,396,416
3Jul 6, 2026 21:224,08946,697,73220,128,00017,086,00094,396,416
4Jul 6, 2026 21:224,10546,879,15819,881,00017,483,00094,396,416
5Jul 6, 2026 21:224,10846,879,70620,086,00017,305,00094,396,416
6Jul 6, 2026 21:224,11346,946,63320,077,00017,360,00094,396,416
7Jul 6, 2026 21:224,11746,930,80619,608,00017,863,00094,396,416
8Jul 6, 2026 21:224,15047,197,90020,183,00017,587,00094,396,416
9Jul 6, 2026 21:224,26648,273,53720,177,00018,649,00094,396,416