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 listJun 2, 2021 18:54Yuriy LyfenkoYuriy LyfenkoScore: 9,583Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2021 18:544,6711,101,957,35442,505,081094,662,656
2Jun 2, 2021 18:544,6921,092,957,70842,693,260094,650,368
3Jun 2, 2021 18:544,7121,100,436,07542,880,046094,658,560
4Jun 2, 2021 18:549,5671,110,605,56971,873,00015,184,00094,547,968
5Jun 2, 2021 18:549,5731,115,606,66571,920,00015,194,00094,547,968
6Jun 2, 2021 18:549,5801,114,685,65072,988,00014,192,00094,547,968
7Jun 2, 2021 18:549,5831,120,650,52571,997,00015,210,00094,552,064
8Jun 2, 2021 18:549,5831,110,145,57571,997,00015,210,00094,547,968
9Jun 2, 2021 18:549,6011,113,781,79871,117,00016,255,00094,547,968
10Jun 2, 2021 18:549,6121,116,597,27767,359,00020,107,00094,547,968
11Jun 2, 2021 18:549,6121,116,920,10870,377,00017,091,00094,547,968
12Jun 2, 2021 18:549,8091,119,289,86171,007,00018,259,00093,241,344