Skip to content

Commit

Permalink
combine block
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Jan 3, 2024
1 parent 7938311 commit aa52bb8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/extensions/jg_json/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ class JgJSONBlocks {
},
text: 'json [json] has key [key] ?'
},
{
opcode: 'json_combine',
blockType: BlockType.REPORTER,
arguments: {
one: {
type: ArgumentType.STRING,
defaultValue: "{}"
},
two: {
type: ArgumentType.STRING,
defaultValue: "{}"
}
},
text: 'combine json [one] and json [two]'
},
{
blockType: BlockType.LABEL,
text: "Arrays"
Expand Down Expand Up @@ -797,6 +812,13 @@ class JgJSONBlocks {
json_array_validate (args) {
return validateArray(args.array).isValid;
}

json_combine (args) {
const one = validateJSON(args.one).object;
const two = validateJSON(args.two).object;

return JSON.stringify(Object.assign(one, two));
}
}

module.exports = JgJSONBlocks;

0 comments on commit aa52bb8

Please sign in to comment.