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

[Enhancement] Serializing using JSON referencing for referenced objects #32

Closed
ajfranzoia opened this issue Sep 23, 2011 · 6 comments
Closed

Comments

@ajfranzoia
Copy link

Hi. I'm currently using Dojo for client side development, and it allows the use of JSON referencing between objects, in a REST context. It'd be great if the bundle allowed this behaviour, since it would simplify the treatment of objects (for example: no need to load a doctrine2 proxy class before serializing and less processing).

More info about JSON referencing: http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/

Possible example:

Object A properties: id and a reference to Object B
Object B properties: id and name

With normal serializing:

Serializing of object A: { id: 1, objectB: { id: 2, name: "myName" } }

Using JSON reference serializing:

Serializing of object A: { id: 1, objectB: { $ref: "/object_b/2" } }

@schmittjoh
Copy link
Owner

If I understand the blog post correctly, this reference scheme would only work for dojo, or is this a general specification?

@ajfranzoia
Copy link
Author

You're right. According to Wikipedia (JSON article):

"Object references
The JSON standard does not support object references, but the Dojo Toolkit illustrates how conventions can be adopted to support such references using standard JSON. Specifically, the dojox.json.ref module provides support for several forms of referencing including circular, multiple, inter-message, and lazy referencing.[29][30]"

This website has more info about it http://json-schema.org/. It seems to be encouraged by Sitepen (Dojo related). Here's the draft sent to IETF http://tools.ietf.org/html/draft-zyp-json-schema-03. But it seems to be expired (http://datatracker.ietf.org/doc/search/?name=json&rfcs=on&activeDrafts=on&oldDrafts=on&search_submit=), so I dont't know if it is actually worth or not to work on this...

@schmittjoh
Copy link
Owner

It definitely sounds interesting, something like this could be implemented using a custom property handler (which are not yet supported).

I'm not sure when I'll have time for this, but patches are also welcome.

@lsmith77
Copy link
Contributor

Dojo guys should at least make the effort to make it an accepted extension of the standard similar to "merge key"

@lsmith77
Copy link
Contributor

err .. got confused there "merge key" is of course Yaml ..

@schmittjoh
Copy link
Owner

I'll close this for now.

We can re-visit it when someone has time to prepare an implementation.

chasewoo pushed a commit to royuan/JMSSerializerBundle that referenced this issue Aug 7, 2013
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

3 participants