Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Recursive Schema
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sebastian Kurfuerst  
View profile  
 More options Nov 4 2010, 6:42 am
From: Sebastian Kurfuerst <sebastian.kurfue...@gmail.com>
Date: Thu, 4 Nov 2010 03:42:01 -0700 (PDT)
Local: Thurs, Nov 4 2010 6:42 am
Subject: Recursive Schema
Hey everybody,

I am looking for how a recursive schema, like a schema for a file
tree, can be defined. Imagine we have the following tree:

{
  name: '/'
  children: [
     {
        name: 'test',
        children: [....]
     }
  ]

}

So, basically I want to evaluate the following:
- make sure "name" is present everywhere
- if there are children, that should be an array.

So something like this:

{
  type: 'object',
  properties: {
    name: {type: 'string'},
    children: {type: 'array', optional: true, items: /*REFERENCE TO
"OBJECT" ABOVE */}
  }

}

It'd be really great if somebody could give me a hint how to reference
the main object in this case.

Thanks a lot,
Sebastian
PS: I know this question has been asked, but I did not find any
answers yet which explained it nicely. Sorry!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gary Court  
View profile  
 More options Nov 13 2010, 2:43 pm
From: Gary Court <gary.co...@gmail.com>
Date: Sat, 13 Nov 2010 12:43:53 -0700
Local: Sat, Nov 13 2010 2:43 pm
Subject: Re: Recursive Schema
You can create references using {"$ref" : "uri"} . All schemas have a
URI, and you can use relative URIs in your references. So, in your
example, your schema would look like:

{
 type: 'object',
 properties: {
   name: {type: 'string'},
   children: {type: 'array', optional: true, items: {'$ref': '#'}}
 }

}

"#" is the fragment tag in a URI, which (on it's own) indicates the
root element of the URI.
You can also reference sub elements. For example, to reference
"children", you would use a relative URI of "#/properties/children".
You can also use named references by adding "id" attributes to your
schemas. So, for example, with the following schema:

{
 id : '#root'
 type: 'object',
 properties: {
   name: {id: '#name', type: 'string'},
   children: {id: '#children', type: 'array', optional: true, items:
{'$ref' : '#root'}}
 }

}

You can now reference children with the URI "#children", or name with "#name".

-Gary

On Thu, Nov 4, 2010 at 4:42 AM, Sebastian  Kurfuerst


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Kurfuerst  
View profile  
 More options Nov 15 2010, 3:40 am
From: Sebastian Kurfuerst <sebastian.kurfue...@gmail.com>
Date: Mon, 15 Nov 2010 00:40:11 -0800 (PST)
Local: Mon, Nov 15 2010 3:40 am
Subject: Re: Recursive Schema
Hello Gary,

that works like a charm as you described! Thanks a bunch for helping
me out :-)

Greets, and keep up the good work!
Sebastian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »