Append to an array of strings
echo '{"user": {"name": "Tom", "age": 27}}' | jq '.user = {"name": "Frank", "age": 25}'
{
"user": {
"name": "Frank",
"age": 25
}
}
echo '{"user": {"name": "Tom", "age": 27}}' | dasel put object -p json -t string -t int '.user' name=Frank age=25
{
"user": {
"age": 25,
"name": "Frank"
}
}
echo '{"user": {"name": "Tom", "age": 27}}' | dasel put document -p json '.user' '{"name": "Frank", "age": 25}'
{
"user": {
"age": 25,
"name": "Frank"
}
}
Append to an array of objects
echo '{"users": [{"name": "Tom"}]}' | jq '.users += [{"name": "Frank"}]'
{
"users": [
{
"name": "Tom"
},
{
"name": "Frank"
}
]
}
echo '{"users": [{"name": "Tom"}]}' | dasel put object -p json -t string '.users.[]' name=Frank
{
"users": [
{
"name": "Tom"
},
{
"name": "Frank"
}
]
}
echo '{"users": [{"name": "Tom"}]}' | dasel put document -p json '.users.[]' '{"name":"Frank"}'
{
"users": [
{
"name": "Tom"
},
{
"name": "Frank"
}
]
}