JSON received from the API:
{
"hello": "world",
"exampledate": "Wednesday, July 19, 2023",
"exampletimestamp": "1630485600",
"listofitems": [
"one",
"two",
"three",
"four"
],
"level1": {
"start": "Very good, this is the value of 'start', right out of the JSON-data",
"level2": [
{
"key": "This is the first value of key in the 'level1'-array",
"data": {
"id": 11111,
"type": "aaaa"
}
},
{
"key": "This is the second value of key in the 'level1'-array",
"data": {
"id": 222,
"type": "bbbb"
}
},
{
"key": "This is the third value of key in the 'level1'-array",
"data": {
"id": 33333333,
"type": "aaaa"
}
},
{
"key": "This is the fourth value of key in the 'level1'-array",
"data": {
"id": 4444,
"type": "aaaa"
}
}
]
}
}hello: worldWednesday, July 19, 2023: 19.07.2023, 00:00:00
1630485600: 01.09.2021, 08:40:10
start: Very good, this is the value of 'start', right out of the JSON-data
level2: This is the first value of key in the 'level1'-array
id: 11111, type: aaaa
level2: This is the second value of key in the 'level1'-array
id: 222, type: bbbb
level2: This is the third value of key in the 'level1'-array
id: 33333333, type: aaaa
level2: This is the fourth value of key in the 'level1'-array
id: 4444, type: aaaa
JSON received from the API:
{
"hello": "world",
"exampledate": "Wednesday, July 19, 2023",
"exampletimestamp": "1630485600",
"listofitems": [
"one",
"two",
"three",
"four"
],
"level1": {
"start": "Very good, this is the value of 'start', right out of the JSON-data",
"level2": [
{
"key": "This is the first value of key in the 'level1'-array",
"data": {
"id": 11111,
"type": "aaaa"
}
},
{
"key": "This is the second value of key in the 'level1'-array",
"data": {
"id": 222,
"type": "bbbb"
}
},
{
"key": "This is the third value of key in the 'level1'-array",
"data": {
"id": 33333333,
"type": "aaaa"
}
},
{
"key": "This is the fourth value of key in the 'level1'-array",
"data": {
"id": 4444,
"type": "aaaa"
}
}
]
}
}Warm welkom! Hier kun je JCI leren kennen door het uit te proberen.
Rechts van deze tekst zou je de instellingen voor blokken moeten zien. Zo niet, klik dan hier op deze tekst.Het blok van de gratis JCI plugin bevat dit voorbeeld: hiermee kun je jezelf vertrouwd maken met de JCI plugin.
Aan de rechterkant wordt automatisch een voorbeeld URL ingevoegd:
https://lucvangerrevink.nl/wp-content/plugins/json-content-importer/json/gutenbergblockexample1.json
Op dezelfde manier wordt een voorbeeldtemplate die overeenkomt met de JSON geleverd door de voorbeeld URL ingevoerd in het vak Template (bewerk het in het vak Template):
hello: {hello}<br>
{exampledate}: {exampledate:datetime,"d.m.Y, H:i:s",0}<br>
{exampletimestamp}: {exampletimestamp:datetime,"d.m.Y, H:i:s",10}<br>
{subloop:level1:-1}
start: {level1.start}<br>
{subloop-array:level1.level2:-1}
level2: {level1.level2.key}
<br>{subloop:level1.level2.data:-1}
id: {level1.level2.data.id}, type: {level1.level2.data.type}<br>
{/subloop:level1.level2.data}
{/subloop-array:level1.level2}
{/subloop:level1}
Door de JSON en deze template samen te voegen, verkrijgen we de uitvoer. Experimenteer gratis met dit voorbeeld.
Door te klikken op “Maak JCI-Template voor JSON” wordt de template automatisch geregenereerd op basis van de JSON.
Hier is een suggestie: invoegen “level1” in het basenode veld.
Je zult een verandering in de uitvoer berichten, omdat de JSON en de template niet meer op elkaar zullen aansluiten.
De “basenode” waarde geeft aan vanaf welk punt de JSON gebruikt moet worden.
Daarom hebben we een andere template nodig. Door “Maak JCI-Template voor JSON” te selecteren, wordt zo’n template gemaakt en in het vak Template gevuld. Door vervolgens op “Probeer template” te klikken, worden de JSON (beginnend bij de node) en de nieuw gemaakte template samengevoegd en weergegeven.
Je kunt ook de sectie rechtsonder “JCI Geavanceerd” openen.
Voer “bb” in in het veld met de tekst “Een van deze woorden moet worden weergegeven:” en voer het getal “3” in in het veld voor “JSON-diepte van de hierboven weergegeven woorden:”. Zie je meteen het verschil?
Debug-info:
Debug: Retrieved from the local cache: https://lucvangerrevink.nl/wp-content/plugins/json-content-importer/json/gutenbergblockexample1.json
Als je de WP shortcode wilt gebruiken: CopyPaste deze shortcode in het shortcode-blok of de WordPress TEXT-editor!
API antwoord:
Inspecteer JSON: kopieer (klik in vak, Strg-A markeert alles, dan invoegen in klembord) de JSON van het volgende vak naar https://jsoneditoronline.org
template:
{subloop-array:level2:-1}level2: {level2.key}
{subloop:level2.data:-1}id: {level2.data.id}, type: {level2.data.type}
{/subloop:level2.data}{/subloop-array:level2}
resultaat:
Instellingen plugin (zie plugin opties):
Cache: actief
Cachetime: 5 minutes
Cachefolder: /home/pw123488/domains/lucvangerrevink.nl/public_html/wp-content/cache/jsoncontentimporter/
oauth Bearer toegangstoets:
hTTP-header standaard useragent:
De samengevoegde JSON en template:
start:
level2:
id: , type:
start:
level2:
id: , type:
{“openapi”:”3.0.1″,”info”:{“title”:”Location”,”description”:”This API allows to get latest known location of a connected vehicle”,”contact”:{},”version”:”1.0″},”servers”:[{“url”:”https://api.volvocars.com/location”}],”paths”:{“/v1/vehicles/{vin}/location”:{“get”:{“tags”:[“Location”],”summary”:”Get last known location”,”description”:”Get last known location”,”operationId”:”GetVehicleLocation”,”parameters”:[{“name”:”vin”,”in”:”path”,”required”:true,”schema”:{“type”:”string”}},{“name”:”vcc-api-operationId”,”in”:”header”,”description”:”A transaction unique id which can be used do identify the transaction in integrated systems”,”schema”:{“type”:”string”}}],”responses”:{“200”:{“description”:”OK”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/LocationResponse”},”example”:{“status”:0,”operationId”:”string”,”data”:{“type”:”string”,”properties”:{},”geometry”:{“type”:”string”,”coordinates”:[0]}}}}}},”400″:{“description”:”Request contains an unaccepted input”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”401″:{“description”:”Unauthorized”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”403″:{“description”:”Forbidden”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”404″:{“description”:”Not Found”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”415″:{“description”:”Unsupported Media Type”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”422″:{“description”:”Unprocessable Entity”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}},”500″:{“description”:”Internal Server Error”,”content”:{“application/json”:{“schema”:{“$ref”:”#/components/schemas/ErrorResponse”},”example”:{“status”:0,”operationId”:”string”,”error”:{“message”:”string”,”description”:”string”}}}}}}}}},”components”:{“schemas”:{“Error”:{“type”:”object”,”properties”:{“message”:{“type”:”string”},”description”:{“type”:”string”}}},”ErrorResponse”:{“type”:”object”,”properties”:{“status”:{“type”:”integer”,”format”:”int32″},”operationId”:{“type”:”string”},”error”:{“$ref”:”#/components/schemas/Error”}}},”Feature”:{“type”:”object”,”properties”:{“type”:{“type”:”string”},”properties”:{“type”:”object”,”additionalProperties”:{“type”:”string”}},”geometry”:{“$ref”:”#/components/schemas/Point”}}},”LocationResponse”:{“type”:”object”,”properties”:{“status”:{“type”:”integer”,”format”:”int32″},”operationId”:{“type”:”string”},”data”:{“$ref”:”#/components/schemas/Feature”}}},”Point”:{“required”:[“coordinates”],”type”:”object”,”properties”:{“type”:{“type”:”string”},”coordinates”:{“maxItems”:3,”minItems”:0,”type”:”array”,”items”:{“type”:”number”,”format”:”double”}}}}},”securitySchemes”:{“apiKeyHeader”:{“type”:”apiKey”,”name”:”vcc-api-key”,”in”:”header”,”description”:”f4d3592e7c7a418eb44e28c4f546e323″},”accessToken”:{“type”:”http”,”scheme”:”bearer”,”bearerFormat”:”JWT”,”description”:”The access token issued by Volvo ID identity system.”}}},”security”:[{“apiKeyHeader”:[]},{“accessToken”:[]}]}
