Affichage des articles dont le libellé est JSON. Afficher tous les articles
Affichage des articles dont le libellé est JSON. Afficher tous les articles
lundi 15 janvier 2024
jsonnet
K8s mixins & jsonnet demo : https://youtu.be/GDdnL5R_l-Y?si=6stnX7hCbdfidIK2&t=413
Jsonnet tester : https://jsonnet.org/
mercredi 21 juin 2023
parse json in terraform
https://www.reddit.com/r/Terraform/comments/c07dgc/using_external_jsons_as_data_source/
data "http" "example" { url = "..." } locals { example_response = jsondecode(data.http.example.body) }
From there you can manipulate that data structure as you need. If you want to produce a map of lists then probably your next step would be to use two nested for expressions. I’m just guessing what you want the values in those lists to look like, but here’s a starting point:
locals { example_rules = { for k, m in local.example_response : k => [ for k, v in m : { key = k value = v } ] } }
jeudi 9 octobre 2014
JavaScript multiline code (JSON description)
It is currently not possible to store a multiline string in javascript. This is annoying since for example storing some JSON data often leads to long data to concatenate or to push into an array.
If you want to avoid this, you can use the following trick, since javascript accepts multiline comments, and returns them to the toString call on a function :
Note 2 :
ECMA-262 5th Edition section 7.8.4 and called LineContinuation : "A line terminator character cannot appear in a string literal, except as part of a LineContinuation to produce the empty character sequence. The correct way to cause a line terminator character to be part of the String value of a string literal is to use an escape sequence such as \n or \u000A."
Note 3 :
"In EcmaScript 6, you'll be able to use backticks for Template Strings, known in the spec as a NoSubstitutionTemplate:
(seen on : http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript)
If you want to avoid this, you can use the following trick, since javascript accepts multiline comments, and returns them to the toString call on a function :
var jsonDescriptionText= function(){/*
[
{
"cat": "Categ1",
"links": [
{
"txt": "text1",
"url": "http://url",
"title": "mouseover field"
}
]
}
]*/}.toString().slice(14,-3);
Note 1 :
This avoids using concatenation for each line :
var longString2="string part1" +
"string part2"or even escaping the new lines :
var longString2="string part1\
string part2"
Note 2 :
ECMA-262 5th Edition section 7.8.4 and called LineContinuation : "A line terminator character cannot appear in a string literal, except as part of a LineContinuation to produce the empty character sequence. The correct way to cause a line terminator character to be part of the String value of a string literal is to use an escape sequence such as \n or \u000A."
Note 3 :
"In EcmaScript 6, you'll be able to use backticks for Template Strings, known in the spec as a NoSubstitutionTemplate:
var htmlString = `Say hello to
multi-line
strings!`;
"(seen on : http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript)
Labels:
ECMA,
javascript,
js,
JSON,
multiline
Inscription à :
Articles (Atom)