mojira.dev
MC-94778

Strict JSON (Quoted Names) doesn't work in /summon

Using the command (in a command block):

summon FallingSand ~0 ~1 ~0 {"Block":"stone","Time":1,"Data":0,"passengers":[{"Block":"redstone_block","Time":1,"Data":0,"passengers":[{"Block":"activator_rail","Time":1,"Data":0,"passengers":[{"Command":"gamerule commandBlockOutput ","id":"MinecartCommandBlock"},{"Command":"fill ~8 ~7 ~5 ~8 ~7 ~5 stained_hardened_clay 13 hollow","id":"MinecartCommandBlock"},{"Command":"say hello world","id":"MinecartCommandBlock"},{"Command":"setblock 2 2 0 chain_command_block 1 replace {\"Command\":\"testfor @e[name=woof]\",\"Auto\":\"1b\"}","id":"MinecartCommandBlock"},{"Command":"kill @e[r=1,type=MinecartCommandBlock]","id":"MinecartCommandBlock"}],"id":"FallingSand"}],"id":"FallingSand"}]}

You notice that it summons a sand block that instantly disappears (not a stone block with a bunch of other things on top).

Trying again with the much simpler `/summon` (by hand):

/summon FallingSand ~0 ~1 ~0 {"Block":"stone","Time":1}

gives the same result although

/summon FallingSand ~0 ~1 ~0 {Block:"stone",Time:1}

works as expected.

This Javascript converts the strict to lenient, if it helps anyone:

text.replace(/\\?"(\w+?)\\?":/g, "$1:");

And it makes the above command work.

Comments 13

NBT data is not JSON.

It is represented as JSON.

Then so would any key/value pair. This is the NBT format, not the JSON format. They are two very different things internally. It would by syntactically incorrect to try using NBT as JSON due to tag-type declarations. For example, Slot:0b cannot be represented as JSON. The "b" declares the datatype as "byte". You cannot declare that as JSON, since "Slot":"0b" is a string, "Slot":0 is an integer, and "Slot":0b is invalid JSON.

@Skylinerw `"Slot":true` and `"Slot":false` work fine.

"Slot" is not a boolean. It's a byte value stating what slot within the inventory an item is.

3 more comments

Ah, that makes more sense. Why is it not JSON? Can I suggest an improvement for it to be JSON?

As @unknown already said, in NBT the data is typed whereas JSON is typeless (because JavaScript is typeless...)

Feature requests may be created on the "minecraftsuggestions" subreddit: https://www.reddit.com/r/minecraftsuggestions/

I though JSON had 8 types, string, number, null, boolean, array, value, object, and whitespace. Source
Also, Javascript is far from typeless, it's dynamic (explanation).

(Sorry if I'm being a bit annoying, just wondering why this is the case)

It's not JSON simply because Notch had created a custom format himself to use (though I do not know his specific reasons for doing so), which has been used since Indev. It would be an enormous amount of work to switch it out now since so much of the game relies on it.

Ben A

(Unassigned)

Unconfirmed

command, json, nbt

Minecraft 15w51b

Retrieved