Home > Mobile >  define json data inside values yaml file
define json data inside values yaml file

Time:11-23

i have the following inside application.properties

TEST=[\
  {"name": "max","id": "123","combination": ${COMBINATION_1}]

how can i translate this array to a valid yaml property inside Values file?

is this a valid syntax? i mean with all this defined variables e.g. combination_1

app:
  pro:
  TEST: |-
    [\
      {"name": "max","id": "123","combination": ${COMBINATION_1}]
  COMBINATION_1: |-
   [\
     {"age": 2, "address": 4}]

CodePudding user response:

The \ in a .properties file is used for multi-line values. You don't need it in YAML block scalars which are multiline anyway:

app:
  pro:
  TEST: |-
    [
      {"name": "max","id": "123","combination": ${COMBINATION_1}}
    ]
  COMBINATION_1: |-
   [
     {"age": 2, "address": 4}
   ]

(You can also write everything in a single line below |-, or keep the ] at the end of the line.)

${COMBINATION_1} is just a part of a value in YAML, just like it is just a part of a value in application.properties. A post-processor needs to take care of it, YAML doesn't do anything with it. Note that I added a } after ${COMBINATION_1} because you also need to close the JSON object.

It is difficult to say more about the variable without knowing which processor does the replacement, but be aware that if it just injects environment variables, COMBINATION_1 must contain a valid JSON value, i.e. if it's a string, the variable must include quotes because unquoted strings are invalid in JSON.

  • Related