From 1a44ca2954486566e22964d857c4d1872935f97c Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Sat, 6 May 2017 16:13:23 +0200 Subject: [PATCH 1/5] Using the output from the xmljson Abdera implementation I think my implementation is correct, and does fix a few things from the original output. --- JSON_and_XML_Conversion.md | 216 ++++++++++++++++++++----------------- 1 file changed, 117 insertions(+), 99 deletions(-) diff --git a/JSON_and_XML_Conversion.md b/JSON_and_XML_Conversion.md index 99778ff..af41052 100644 --- a/JSON_and_XML_Conversion.md +++ b/JSON_and_XML_Conversion.md @@ -606,112 +606,130 @@ The Abdera convention is what is used within the Apache Abdera project to show A ### JSON Representation -I'm not entirely sure if this is accurate since I did it by hand from inference. - ({ "reports": { - "entry": [{ - "id": "tag:open311.sfgov.org,2010-04-15:\/dev\/V1\/reports\/637619.xml", - "title": "A large tree branch is blocking the road", - "updated": "2010-04-13T18:30:02-05:00", - "link": { - "rel": "self", - "href": "http:\/\/open311.sfgov.org\/dev\/V1\/reports\/637619.xml" - }, - "author": { - "name": "John Doe" - }, - "georss:point": "40.7111 -73.9565", - "category": { - "attributes": { - "label": "Damaged tree", - "term": "tree-damage", - "scheme": "https:\/\/open311.sfgov.org\/dev\/V1\/categories\/006.xml" - }, - "children": ["006"] - }, - "content": { - "children": [{ - "report_id": "637619", - "address": "1600 Market St, San Francisco, CA 94103", - "description": "A large tree branch is blocking the road", - "status": "created", - "status_notes": [], - "policy": "The City will inspect and require the responsible party to correct within 24 hours and\/or issue a Correction Notice or Notice of Violation of the Public Works Code" - }], - "attributes": { - "type": "xml" + "children": [ + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637619.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "href": "http://open311.sfgov.org/dev/V1/reports/637619.xml", + "rel": "self" + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "type": "xml" + }, + "children": [ + { + "report_id": 637619, + "address": "1600 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": null, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } } - } - }, - { - "id": "tag:open311.sfgov.org,2010-04-15:\/dev\/V1\/reports\/637620.xml", - "title": "A large tree branch is blocking the road", - "updated": "2010-04-13T18:30:02-05:00", - "link": { - "rel": "self", - "href": "http:\/\/open311.sfgov.org\/dev\/V1\/reports\/637620.xml" - }, - "author": { - "name": "John Doe" - }, - "georss:point": "40.7111 -73.9565", - "category": { - "attributes": { - "label": "Damaged tree", - "term": "tree-damage", - "scheme": "https:\/\/open311.sfgov.org\/dev\/V1\/categories\/006.xml" - }, - "children": ["006"] }, - "content": { - "children": [{ - "report_id": "637620", - "address": "1600 Market St, San Francisco, CA 94103", - "description": "A large tree branch is blocking the road", - "status": "created", - "status_notes": [], - "policy": "The City will inspect and require the responsible party to correct within 24 hours and\/or issue a Correction Notice or Notice of Violation of the Public Works Code" - }], - "attributes": { - "type": "xml" + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637620.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "href": "http://open311.sfgov.org/dev/V1/reports/637620.xml", + "rel": "self" + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "type": "xml" + }, + "children": [ + { + "report_id": 637620, + "address": "56 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": null, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } } - } - }, - { - "id": "tag:open311.sfgov.org,2010-04-15:\/dev\/V1\/reports\/637620.xml", - "title": "A large tree branch is blocking the road", - "updated": "2010-04-13T18:30:02-05:00", - "link": { - "rel": "self", - "href": "http:\/\/open311.sfgov.org\/dev\/V1\/reports\/637620.xml" }, - "author": { - "name": "John Doe" - }, - "georss:point": "40.7111 -73.9565", - "category": { - "attributes": { - "label": "Damaged tree", - "term": "tree-damage", - "scheme": "https:\/\/open311.sfgov.org\/dev\/V1\/categories\/006.xml" - }, - "children": ["006"] - }, - "content": { - "children": [{ - "report_id": "637620", - "address": "1600 Market St, San Francisco, CA 94103", - "description": "A large tree branch is blocking the road", - "status": "created", - "status_notes": [], - "policy": "The City will inspect and require the responsible party to correct within 24 hours and\/or issue a Correction Notice or Notice of Violation of the Public Works Code" - }], - "attributes": { - "type": "xml" + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637621.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "href": "http://open311.sfgov.org/dev/V1/reports/637621.xml", + "rel": "self" + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "type": "xml" + }, + "children": [ + { + "report_id": 637621, + "address": "1800 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": null, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } } } - }] + ] } }); @@ -1053,4 +1071,4 @@ See [GeoJSON.org](http://geojson.org) } } ] - } \ No newline at end of file + } From 36c93db718e16f8f0c69e5a01c173f149a00eb45 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Sun, 7 May 2017 13:14:38 +0200 Subject: [PATCH 2/5] Also add the filtered-out "ns" keys. --- JSON_and_XML_Conversion.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/JSON_and_XML_Conversion.md b/JSON_and_XML_Conversion.md index af41052..60b7a6d 100644 --- a/JSON_and_XML_Conversion.md +++ b/JSON_and_XML_Conversion.md @@ -608,6 +608,9 @@ The Abdera convention is what is used within the Apache Abdera project to show A ({ "reports": { + "attributes": { + "ns": "http://www.w3.org/2005/Atom" + }, "children": [ { "entry": { @@ -634,6 +637,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A }, "content": { "attributes": { + "ns": "http://open311.org/spec/georeport-v1", "type": "xml" }, "children": [ @@ -674,6 +678,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A }, "content": { "attributes": { + "ns": "http://open311.org/spec/georeport-v1", "type": "xml" }, "children": [ @@ -714,6 +719,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A }, "content": { "attributes": { + "ns": "http://open311.org/spec/georeport-v1", "type": "xml" }, "children": [ From 77fd17c2eafd86ce7223c8521d1b249a5dfd9969 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Sun, 7 May 2017 13:29:12 +0200 Subject: [PATCH 3/5] Small fixes --- JSON_and_XML_Conversion.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/JSON_and_XML_Conversion.md b/JSON_and_XML_Conversion.md index 60b7a6d..9293cbb 100644 --- a/JSON_and_XML_Conversion.md +++ b/JSON_and_XML_Conversion.md @@ -618,8 +618,10 @@ The Abdera convention is what is used within the Apache Abdera project to show A "title": "A large tree branch is blocking the road", "updated": "2010-04-13T18:30:02-05:00", "link": { - "href": "http://open311.sfgov.org/dev/V1/reports/637619.xml", - "rel": "self" + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637619.xml", + "rel": "self" + } }, "author": { "name": "John Doe" @@ -659,8 +661,10 @@ The Abdera convention is what is used within the Apache Abdera project to show A "title": "A large tree branch is blocking the road", "updated": "2010-04-13T18:30:02-05:00", "link": { - "href": "http://open311.sfgov.org/dev/V1/reports/637620.xml", - "rel": "self" + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637620.xml", + "rel": "self" + } }, "author": { "name": "John Doe" @@ -700,8 +704,10 @@ The Abdera convention is what is used within the Apache Abdera project to show A "title": "A large tree branch is blocking the road", "updated": "2010-04-13T18:30:02-05:00", "link": { - "href": "http://open311.sfgov.org/dev/V1/reports/637621.xml", - "rel": "self" + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637621.xml", + "rel": "self" + } }, "author": { "name": "John Doe" From a6e0a31904814a1c21253b976d013978b0866e2e Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 8 May 2017 10:51:03 +0200 Subject: [PATCH 4/5] Adding Cisco Cobra convention (variant to Abdera) --- JSON_and_XML_Conversion.md | 157 +++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/JSON_and_XML_Conversion.md b/JSON_and_XML_Conversion.md index 9293cbb..5a91b45 100644 --- a/JSON_and_XML_Conversion.md +++ b/JSON_and_XML_Conversion.md @@ -745,6 +745,163 @@ The Abdera convention is what is used within the Apache Abdera project to show A } }); +The Cobra Convention +--------------------- + +The Cobra convention is what is used within the Cisco ACI product (CobraSDK) and is very closely related to the Abdera convention. The difference is that an attributes dictionary is always present if multiplte children exist (even when empty), the attributes are sorted by name, and it also does not convert xmlstring values, every value is considered a string in the Cobra convention. + +### References + +- **Documentation**: +- **Cisco CobraSDK (Python)**: + +### JSON Representation + + ({ + "reports": { + "attributes": { + "ns": "http://www.w3.org/2005/Atom" + }, + "children": [ + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637619.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637619.xml", + "rel": "self" + } + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "ns": "http://open311.org/spec/georeport-v1", + "type": "xml" + }, + "children": [ + { + "report_id": "637619", + "address": "1600 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": { + "attributes": {} + }, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } + } + }, + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637620.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637620.xml", + "rel": "self" + } + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "ns": "http://open311.org/spec/georeport-v1", + "type": "xml" + }, + "children": [ + { + "report_id": "637620", + "address": "56 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": { + "attributes": {} + }, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } + } + }, + { + "entry": { + "id": "tag:open311.sfgov.org,2010-04-15:/dev/V1/reports/637621.xml", + "title": "A large tree branch is blocking the road", + "updated": "2010-04-13T18:30:02-05:00", + "link": { + "attributes": { + "href": "http://open311.sfgov.org/dev/V1/reports/637621.xml", + "rel": "self" + } + }, + "author": { + "name": "John Doe" + }, + "{http://www.georss.org/georss}point": "40.7111 -73.9565", + "category": { + "attributes": { + "label": "Damaged tree" + "scheme": "https://open311.sfgov.org/dev/V1/categories/006.xml", + "term": "tree-damage", + }, + "children": [ + "006" + ] + }, + "content": { + "attributes": { + "ns": "http://open311.org/spec/georeport-v1", + "type": "xml" + }, + "children": [ + { + "report_id": "637621", + "address": "1800 Market St, San Francisco, CA 94103", + "description": "A large tree branch is blocking the road", + "status": "created", + "status_notes": { + "attributes": {} + }, + "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" + } + ] + } + } + } + ] + } + }); + JsonML Convention ----------------- From 5083964998d1933e702de26433731ca333188b45 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Mon, 8 May 2017 11:05:53 +0200 Subject: [PATCH 5/5] Small fixes --- JSON_and_XML_Conversion.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JSON_and_XML_Conversion.md b/JSON_and_XML_Conversion.md index 5a91b45..926e55e 100644 --- a/JSON_and_XML_Conversion.md +++ b/JSON_and_XML_Conversion.md @@ -648,7 +648,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A "address": "1600 Market St, San Francisco, CA 94103", "description": "A large tree branch is blocking the road", "status": "created", - "status_notes": null, + "status_notes": {}, "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" } ] @@ -691,7 +691,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A "address": "56 Market St, San Francisco, CA 94103", "description": "A large tree branch is blocking the road", "status": "created", - "status_notes": null, + "status_notes": {}, "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" } ] @@ -734,7 +734,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A "address": "1800 Market St, San Francisco, CA 94103", "description": "A large tree branch is blocking the road", "status": "created", - "status_notes": null, + "status_notes": {}, "policy": "The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code" } ] @@ -748,7 +748,7 @@ The Abdera convention is what is used within the Apache Abdera project to show A The Cobra Convention --------------------- -The Cobra convention is what is used within the Cisco ACI product (CobraSDK) and is very closely related to the Abdera convention. The difference is that an attributes dictionary is always present if multiplte children exist (even when empty), the attributes are sorted by name, and it also does not convert xmlstring values, every value is considered a string in the Cobra convention. +The Cobra convention is what is used within the Cisco ACI product (CobraSDK) and is very closely related to the Abdera convention. The difference is that an attributes dictionary is always present if multiple children exist (even when empty), the attributes are sorted by name, and every value is considered a string in the Cobra convention (it does not automatically convert to types). ### References