How to substitute array values for Octopus AWS Lambda functions - aws-lambda

Consider the following
{
"foo": [ "cat", "dog" ]
}
I want to replace these values in Octopus with
{
"foo": [ "wolf" ]
}
How do I do it with Octopus? I can't replace with ["wolf"] in the value as I receive an error: Invalid JSON: Expecting ','.
I'm using dotnet core.

How are you replacing the variable value?
This should be possible using Structured Configuration Variables with a variable named foo set to ["wolf"].

Related

Pass a parameter as list to argo workflow

I have the following JSON file which will be passed as a parameter file to an Argo workflow:
{
"keys": [
"key1",
"key2",
"key3"
]
}
Accessing "keys" like '{{inputs.parameters.keys}}' reads keys as a string instead of a list.
Is it possible to read an input parameter from a parameter file as a list of values?
Within an Argo Workflow, parameters are always strings.
You can use expression templates to retrieve information from the stringified list.
value: '{{=jsonpath(inputs.parameters.keys, "$.0")}}' # get the first item

How to update value in key using jq inside a file in shell script?

I have file like this(exact format):
{ "test": "10" }
{ "games": "30" }
{ "REPOSITORY": "5"}
I want to update the value of key. For example games to 66. So the new file would be:
{ "test": "10" }
{ "games": "66" }
{ "REPOSITORY":"5"}
I used jq with combination of a temporary file
tmp=$(mktemp);
jq '.games = "66"' pair.json > "$tmp" && mv "$tmp" change.json
but got this kind of output.
{
"test": "10",
"games": "66"
}
{
"games": "66"
}
{
"REPOSITORY": "5",
"games": "66"
}
where games is written all 3 whereas I just want it be updated only at its position.
Furthermore i want the value to be updated using bash variable but that I can try to figure out using --arg after I resolve this issue. Pls assist here.
Your input is a stream of objects. As such your filter expression, .games = "66" asserts that the record games is present in each of the object present in the stream.
To update the specific object alone, select it first and assign the required value or update it.
jq -c 'select(has("games")).games = "66"'
To answer OP's clarification on how to do the same with variables, do
jq -c --arg key "games" 'select(has($key))[$key] = "555"'
A simple solution is using select with assignment. select will return the special value empty if the condition does not match and the input value if it does match.
select(.games).games = "66"
jq -c to generate compact format, i.e. one JSON object/document per line.
To handle arbitrary names, change the syntax slightly:
select(.["games"])["games"] = "66"
and used with arguments passed via CLI:
jq -r --arg key "$var" 'select(.[$key])[$key] = "66"'

How to extract a item from compose powerautomate

How to extract a item from compose.
For example I have a compose item like below,
How to get "AAAA" only and input create a item to sharepoint List.
I tyied
outputs('Select')?['Title']
Appear Error msg like that "Array elements can only be selected using an integer index."
Compose
{ "Titile" : "AAAA",
"TitleB" : "BBBB",
"TitleC" : "CCCC",
"TitleD" * "DDDD}
Firstly, your JSON is far from being valid so I've made some assumptions and have included it here with what I used for my answer ...
{
"TitleA": "AAAA",
"TitleB": "BBBB",
"TitleC": "CCCC",
"TitleD": "DDDD"
}
My suggestion is that you use variables instead of compose.
Here is my flow ...
With the second step, this is the expression I used ...
variables('Json Object')?['TitleA']
This is the end result ...

Apache NiFi EvaluateJson Path starts with $ (dollar sign)

How would I manage to set the extraction path of a node that is names $?
I got this JSON and I have tried to escape it like $$ but I get nothing.
{
"Name" : "Bla",
"$" : "A"
}
Any ideas?
according to jsonpath expressions
it's possible to access keys with dot-notation or bracket-notation
bracket–notation should allow you to access the keys with non-word chars like ., $, etc.
assume you have json:
{
"the.name": "boo",
"$": "foo"
}
in this case to access key "the.name" you have to use brackets-notation:
$['the.name']
the same idea with "$" key:
$['$']

Read values from puppet template

Hi I've a puppet template with below values.
myfile.erb
name = "abc"
desg = "engineer"
Sal = "10000"
And I try to read these values from my puppet script like below
init.pp
$value = template("d:/puppet/modules/mymodule/templates/myfile.erb")
now my $value is containing all values from the myfile.erb file. Is there any way to divide the values like $value[0], $value[1] etc..
I want to display only "abc" "engineer" "1000"
When your data lookup starts getting complicated, I highly recommend you move away from templates towards an external data lookup, like hiera. For a guide to setting up, I've written a small tutorial here. You can substitute yaml for json.
Your hiera file could look as simple as this:
{
"myfile": {
"name": "abc",
"desg": "engineer"
"Sal": "10000"
}
}
And then in your file:
$vars = hiera('myfile')
// Gives "abc"
$vars['name']
// Gives "engineer"
$vars['desg']

Resources