Generic-Syntax for object mapping and graph

JSON and XML shortcomings

JSON-LD
{
	"@type": "http://schema.org/Article",
	"identifier": "5Pl8d4"
	"author": "Author name",
	"datePublished": "2020-1-1",
	"image": {
		"@type": "http://schema.org/imageObject",
		"url": "http://example.com/image.png",
		"height": 600,
		"width": 800
	},
	"publisher": {
		"@type": "http://schema.org/Organization",
		"name": "Publisher name",
		"logo": {
			"@type": "http://schema.org/imageObject",
			"url": "http://example.com/logo.png"
		}
	}
}
GS
<http://schema.org/Article identifier='5Pl8d4' {
  author= "Author name"
  datePublished= "2020-1-1"
  image= <http://schema.org/imageObject {
  	url= "http://example.com/image.png"
  	height=600
  	width=800
  }>
  <#"String properties can also be defined in attributes">
  publisher= <http://schema.org/Organization name='Publisher name' {
  	logo=<http://schema.org/imageObject url='http://example.com/logo.png'>
  }>
}>

JSON-LD is today one of the best languages for serializing a typed objects graph. But the inability to name objects in JSON has two flaws:

On the other hand, XML lacks a key-node pair structure and is not well suited for this purpose.

GS solves these problems by combining JSON object properties and XML named object features.

GS-graph language

GS-graph is a secure library for building and serializing complex and recursive graphs of typed objects. At parsing stage, according to its configuration, typed objects are instantiated, properties are assigned and explicitly authorized methods can be called.

<?graph>
<User account=2197 %id=JOM {
  name= "John Merting"
  chief= <%ref "MAD">
  groups= [
    <%ref "MGRS">
  ]
}>
<User account=2123 %id=MAD {
  name= "Marc Dublof"
  groups=[
    <Group id=36564 %id=admins {
      name= "Administrators"
    }>
  ]
  addTemporaryDelegation = <%call [
	<%ref "JOM">
  	<Date day='2019-12-22'>
  	14
  ]>
}>
<Group id=35 %id=MGRS{
  name= "Managers"
}>

GS-graph uses the GS attribute and node special type % instruction to link objects and call methods at the building stage.

A first experimental GS-graph building implementation is available in Typescript and Javascript. Source code is available at https://github.com/generic-syntax/gs-js.