MSON to describe object attributes in blueprint
Asked Answered
G

1

1

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.

Garland answered 31/7, 2015 at 18:7 Comment(0)
G
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!

Gink answered 3/8, 2015 at 8:3 Comment(3)
Hey Daniel, thank you for that. I am using aglio to render this. Your example is one I have already used in the past and still not what I am expecting. Aglio only renders the photos array in the schema. See here: gist.github.com/aichholzer/…Garland
Perhaps an issue with aglio?Garland
@Aichholzer this is currently handled behind the scenes by a library called boutique.js (through the aglio dependency drafter.js). It's possible it isn't working properly. The plan is to replace it soon by the C++ implementation of Drafter which has (or will have) similar (faster, better) functionality.Gink

© 2022 - 2024 — McMap. All rights reserved.