问题
I have an issue similar to what is described here.
I have a JSON that looks like this:
{
"photos": [
{
"key": "y37dmj10jkwof/moOIUB8912JKVgh",
"caption": "A world of gamers.",
"tags": [
"game",
"japan"
],
"attributes": {
"copyright": true,
"use": [
"public",
"private"
]
}
}
]
}
and I am trying to describe the attributes using MSON, to render the blueprint. However, I am not successful at it. Here is my attempt:
+ Attributes (required, object)
+ photos (required, array)
+ (object)
+ key (required, string) - Photo key
+ caption (required, string) - Photo caption
+ tags (required, array)
+ game (string)
+ japan (string)
+ attributes (required, object)
+ (object)
+ copyright: true (required, boolean)
+ uses (required, array)
+ public (string)
+ private (string)
Ideas anyone? Any input would be highly appreciated.
回答1:
Here's an example that I think does what you want:
+ Attributes
+ photos (required, array)
+ (object)
+ key: y37dmj10jkwof/moOIUB8912JKVgh (required) - Photo key
+ caption: A world of gamers (required) - Photo caption
+ tags: game, japan (required, array)
+ attributes (required)
+ copyright: true (required, boolean)
+ use: public, private (required, array)
Note that you can put the sample values for the arrays as a comma separated list, and there's usually no need to explicitly state when the type is a string
or object
(unless it has no name). As for the attributes
object, you can put the keys on it directly, no need to make another level with + (object)
Hope this helps!
来源:https://stackoverflow.com/questions/31752483/mson-to-describe-object-attributes-in-blueprint