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 22, 2024 02:16Yuriy LyfenkoYuriy LyfenkoScore: 4,216Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2024 02:164,194562,668,61530,132,0008,035,00092,864,512
2Apr 22, 2024 02:164,199564,057,53629,163,0009,050,00092,872,704
3Apr 22, 2024 02:164,203563,243,17830,197,0008,052,00092,913,664
4Apr 22, 2024 02:164,204563,082,23230,203,0008,054,00092,942,336
5Apr 22, 2024 02:164,205560,481,70931,218,0007,049,00092,962,816
6Apr 22, 2024 02:164,211570,308,22029,247,0009,076,00092,860,416
7Apr 22, 2024 02:164,216562,437,03030,288,0008,076,00092,966,912
8Apr 22, 2024 02:164,512615,044,79341,061,929094,740,480
9Apr 22, 2024 02:164,526597,866,80741,182,216094,736,384
10Apr 22, 2024 02:164,528607,811,15141,203,328094,744,576
11Apr 22, 2024 02:164,782575,856,44829,013,00014,506,00092,946,432
12Apr 22, 2024 02:164,887580,753,66730,319,00014,149,00092,868,608