Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
46
Task/JSON/Ol/json.ol
Normal file
46
Task/JSON/Ol/json.ol
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
(import (lib json))
|
||||
(import (owl parse))
|
||||
|
||||
(define o (parse json-parser (str-iter "
|
||||
{
|
||||
'name': 'John',
|
||||
'full name': 'John Smith',
|
||||
'age': 42,
|
||||
'married': false,
|
||||
'address': {
|
||||
'street': '21 2nd Street',
|
||||
'city': 'New York',
|
||||
},
|
||||
'additional staff': [
|
||||
{
|
||||
'type': 'numbers',
|
||||
'numbers': [ 1, 2, 3, 4 ]
|
||||
},
|
||||
{
|
||||
'type': 'phone',
|
||||
'number': '222 222-2222'
|
||||
}
|
||||
]
|
||||
}") #f #f #f))
|
||||
(print o)
|
||||
|
||||
(print-json-with display o)
|
||||
(print-json-with display {
|
||||
'name "John"
|
||||
'|full name| "John Smith"
|
||||
'age 42
|
||||
'married #false
|
||||
'address {
|
||||
'street "21 2nd Street"
|
||||
'city "New York"
|
||||
}
|
||||
'|additional staff| [
|
||||
{
|
||||
'type "numbers"
|
||||
'numbers [ 1 2 3 4 ]
|
||||
}
|
||||
{
|
||||
'type "phone"
|
||||
'number "222 222-2222"
|
||||
}
|
||||
]
|
||||
28
Task/JSON/XQuery/json.xquery
Normal file
28
Task/JSON/XQuery/json.xquery
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
let $json := '
|
||||
{
|
||||
"Astring" : "string-value",
|
||||
"Anumber" : 5.7,
|
||||
"Anull" : null,
|
||||
"Aarray" : ["One","Two", 3],
|
||||
"Aobject" : {
|
||||
"key1": "value1",
|
||||
"key2": "value2"
|
||||
},
|
||||
"Atrue" : true,
|
||||
"Afalse" : false
|
||||
}
|
||||
'
|
||||
let $xml := json-to-xml($local:json)
|
||||
return (
|
||||
"XPath fn:json-to-xml#1 function:"
|
||||
,""
|
||||
,$xml
|
||||
,""
|
||||
,"Round trip, using fn:xml-to-json#1:"
|
||||
,""
|
||||
,xml-to-json($xml)
|
||||
,""
|
||||
,"Using BaseX json:parse#2 function to create an XPath 3.1 map:"
|
||||
,""
|
||||
,json:parse($local:json, map{"format":"xquery"})
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue