Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access parent data #130

Open
pmogren opened this issue Jan 13, 2014 · 2 comments
Open

How to access parent data #130

pmogren opened this issue Jan 13, 2014 · 2 comments

Comments

@pmogren
Copy link

pmogren commented Jan 13, 2014

Hello,

Given a JSON document like this:

"a": {
  "b": "bVal"
  "c": {
    "d": [
      { "e" : "e1" },
      { "e" : "e2" }
     ]
   }
}

Is there any way the URI template of a schema-described link on the items of array 'd' could reference the value of 'b'? For example I am thinking of a URI template like "/example{?e}&b={parent.parent.parent.b}" which on the first item in 'd' would come out to "/example?e=e1&b=bVal"

@geraintluff
Copy link
Contributor

Not in v4, I'm afraid.

It's expected to be in v5, as per [this proposal](https://github.com/json-schema/json-schema/wiki/Extended-templating-syntax-(v5-proposal\)). It would be something like:

{
    "links": [
        "href": {
            "template": "/example{?e,b}",
            "vars": {
                "b": "3/b"
            }
        }
    ]
}

In that example, "e" is treated as a plain variable name, but the value for "b" is resolved using a Relative JSON Pointer that says "go up three levels, then into the b property".

The moment a proposal for v5 is released, I'll put this functionality into Jsonary.

@pmogren
Copy link
Author

pmogren commented Jan 14, 2014

Thanks for the response.

From: Geraint [mailto:notifications@github.com]
Sent: Tuesday, January 14, 2014 11:09 AM
To: jsonary-js/jsonary
Cc: Paul Mogren
Subject: Re: [jsonary] How to access parent data (#130)

Not in v4.

It's expected to be in v5, as per this proposalhttps://github.com/json-schema/json-schema/wiki/Extended-templating-syntax-(v5-proposal). It would be something like:

{

"links": [

    "href": {

        "template": "/example{?e,b}",

        "vars": {

            "b": "3/b"

        }

    }

]

}

In that example, "e" is treated as a plain variable name, but the value for "b" is resolved using a Relative JSON Pointer that says "go up three levels, then into the b property".

The moment a proposal for v5 is released, I'll put this functionality into Jsonary.


Reply to this email directly or view it on GitHubhttps://github.com//issues/130#issuecomment-32278182.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants