mdsol / hale

HALe specification draft
9 stars 3 forks source link

Fix/meta embedding #13

Closed csavage-mdsol closed 10 years ago

csavage-mdsol commented 10 years ago

Previously, under "_embedded", the reserved key "_meta" was used instead of property names and values that are either a Resource Object or an array of Resource Objects.

Also made a develop branch.

ping @sheavalentine-mdsol

sheavalentine-mdsol commented 10 years ago

Looks good to me. I'll mere in 20 unless there are other comments.

csavage-mdsol commented 10 years ago

Suprisingly, I have a comment.

In this example:

{
    "_meta": {
        "data": {
            "options": [
                0,
                1,
                2
            ],
            "value": 0
        },
        "data1": {
            "_ref": [
                "data"
            ],
            "value": 1
        },
        "something": {
            "max": 1,
            "value": 2
        },
        "something_else": {
            "_ref": [
                "data1",
                "something"
            ]
        },
        "_embedded": {
            "item": {
                "_meta": {
                    "embedded_something": {
                        "_ref": [
                            "something_else"
                        ]
                    }
                }
            }
        }
    }
}

"_embedded" is a property of "_meta", is that actually valid?

fosrias commented 10 years ago

@csavage-mdsol Editing JSON is such a joy. It is not correct. _embedded is a top-level reserved property. Good eye.

csavage-mdsol commented 10 years ago

Heh. Just to be clear @fosdev, a hale instead of "_embedded" however should be valid, so:

{ "_meta": {
           ...
          "item": { <hale_doc> }
   }
}

good

{ "_meta": {
  ...
  "_embedded": {<blah>}
  }
}

bad ?

fosrias commented 10 years ago

Good

{ 
    "_meta" : {
        <blah>
    },
   "_embedded": {
        <blah>
    }
}

Am I understanding?

csavage-mdsol commented 10 years ago

err, perhaps Im confusing myself, but what Im trying to say is that we should be able to plop a valid hale doc in "_meta"

so this:

{
  "_meta": {
     "item": {
          "_meta": {...},
          "_embedded": {...}
      }
  },
  "_embedded": { ... }
}
csavage-mdsol commented 10 years ago

Trying to ask, not say.

sheavalentine-mdsol commented 10 years ago

I think what you're going for specifically is:

{
  "_meta": {
     "item": {
          "_meta": {...},
          "_embedded": {...}
      }
  },
  "_embedded": {"item": {"_ref": "item"}}
}

is interpreted as

{
  "_meta": {
     "item": {
          "_meta": {...},
          "_embedded": {...}
      }
  },
  "_embedded": {"item": {
          "_meta": {...},
          "_embedded": {...}
      }}
}
fosrias commented 10 years ago

@csavage-mdsol Interesting question. I think that you could, but not necessarily rely on it being recognized as a hale document per say. The _meta tag just affords json objects with no interpretation of what they are. However, there is nothing preventing you from doing that and then using a meta reference to put that somewhere else where it needs to be a hale document. Make any sense?

fosrias commented 10 years ago

@csavage-mdsol @sheavalentine-mdsol's last comment is basically saying what I was.

csavage-mdsol commented 10 years ago

@fosdev yeah, makes sense. @sheavalentine-mdsol's example is the use case I had in mind. I'll be making an update to this PR shortly.

csavage-mdsol commented 10 years ago

@sheavalentine-mdsol @fosdev any further comments?