Use raw json in Command attribute (/setblock) [duplicate]

I'm trying to setblock a command block with variable data in it. I want to make a variable sized array with an armor stand, and read a custom tag at a variable position. This position should be stored in a scoreboard as well.

Further information:

  • Minecraft version 1.13.2
  • Singleplayer mode

I've already tried this command:

/setblock ~ ~2 ~ minecraft:command_block{Command:{"text":"execute store result score posN replay run data get entity highfrequent Pos["},{"score":{"name":"#this","objective":"replay"}},{"text":"]"}} replace

But it doesn't work. It couldn't place the block, and I think I did something wrong with the JSON syntax.

My objective is to have an array which I can read at a variable position.

If anybody has an idea of how to do this, I would be glad to hear it.


The command inside a command block is a regular string, not a JSON component. Since there's also no way to convert a JSON component into a normal string, you can't use it as the command inside a command block.