If you submit a daycare registration form where full_name is "Mike Plusch", state is "MA", and the children have names of "Alexi", "Sophie", and "Charlotte" with ages of 7, 5, and 4, the nested data would have this structure:
| a thing | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| children |
| ||||||||||||||||||
| state | MA | ||||||||||||||||||
| full_name | Mike Plusch | ||||||||||||||||||
http://daycare/register?full_name=Mike%20Plusch&state=MA&children.0._parent=child&children.0.name=Alexi&children.0.age=7&children.1._parent=child&children.1.name=Sophie&children.1.age=5&children.2._parent=child&children.2.name=Charlotte&children.2.age=4
When whitespace is added for readability, the above URL is:
http://daycare/register?
full_name=Mike Plusch
&state=MA
&children.0._parent=child
&children.0.name=Alexi
&children.0.age=7
&children.1._parent=child
&children.1.name=Sophie
&children.1.age=5
&children.2._parent=child
&children.2.name=Charlotte
&children.2.age=4
The same data in ConciseXML Encoding is:
<thing>
full_name="Mike Plusch"
state="MA"
children=<v> <child> name="Alexi" age=7 </child>
<child> name="Sophie" age=5 </child>
<child> name="Charlotte" age=4 </child>
</v>
</thing>
ConciseURI and XML can both represent hierarchial data structures and complex types. The primary difference is that ConciseURI syntax is compatible with URI query and standard Web browser form submissions.
FILExt, the file extension source, has a record for ConciseURI Syntax.
When saving files in ConciseURI, the extension is .cus, which stands for ConciseURI Syntax. The mime type for ConciseURI is mime/cus
Here are a number of examples of ConciseURI syntax:
ConciseURI: ?first=Mike&last=Plusch
Used on a query string: http://test/?first=Mike&last=Plusch
ConciseXML/Water: <thing first="Mike" last="Plusch"/>
JavaScript: {first:"Mike", last:"Plusch"}
HTML form: <FORM><INPUT name="first" value="Mike"/><INPUT name="last" value="Plusch"/></FORM>
If the first character is a question mark, the remainder of the data represents the fields of a non-primitive object.
Use of parentheses to represent structures and objects:
ConciseURI: ?y=one&z.x=test
ConciseXML: <thing y="one" z=<thing x="test"/> />
JavaScript: {y:"one", z:{x:"test"} }
Support for keyed and unkeyed arguments. Unkeyed arguments become ordered vector/integer keys.
ConciseURI: ?keyed_arg=5&unkeyed_value
ConciseXML: <thing keyed_arg=5 0="unkeyed_value"/>
JavaScript: {keyed_arg:5, 0:"unkeyed_value"}
Values that look like a number are automatically converted into a number, otherwise they get converted into a string.
ConciseURI: ?x=5&y=8px
ConciseXML: <thing x=5 y="8px"/>
JavaScript: {x:5, y:"8px"}
Keys that look like a number are treated as numbers, otherwise they are treated as strings.
ConciseURI: ?test&2y=8px
ConciseXML: <thing 0="test" 2y="8px"/>
JavaScript: {0:"test", 2y:"8px"}
Values that look like primitive values are treated as such
ConciseURI: ?m=true&n=null&k=false
ConciseXML: <thing m=true n=null k=false/>
JavaScript: {m:true, n:null, k:false}
Examples of how a ConciseXML expression would be represented in a ConciseURI query string
Simple numeric values
ConciseXML: <thing a=5/> ConciseURI: ?a=5
Simple string values
ConciseXML: <thing a="stuff"/> ConciseURI: ?a=stuff
Multiple fields
ConciseXML: <thing b="foo" a=5/> ConciseURI: ?a=5&b=foo
Nested values using parentheses
ConciseXML: <thing a=<thing x=5/>/> ConciseURI: ?a.x=5
Unkeyed arguments and null values
ConciseXML: <thing 0=<thing x=5/> 1=null/> ConciseURI: ?0.x=5&1=null
When used as a file format, ConciseURI can represent simple primitive
values. A file representing a boolean true would contain the text true.
A file representing the value "hello" would contain the text hello.
ConciseURI can also support typed instances. To indicate the type, set the "_parent" field to the name of a type.
ConciseXML: <boat color="red"/> ConciseURI: ?_parent=boat&color=red
An example with nested typed objects
ConciseXML: <boat color="red" owner=<person name="Bob"/>/> ConciseURI: ?_parent=boat&color=red&owner._parent=person&owner.name=Bob
Although the _parent could be specified at the top level in a
URI query string, that would only change the type of object that
holds the arguments. http://domain/?_parent=boat&color=red
would not pass in an instance of boat, but the following would pass
in a boat in the myboat argument: http://domain/?myboat._parent=boat&myboat.color=red