Branislav Katreniak
2017-08-31 09:47:12 UTC
Hi all,
I think about json.listasObject annotation.
````capnp
using json = using import "/capnp/json .capnp";
struct Team {
struct Person {
id @0 :Text;
name @1 :Text;
height @2 :Float64;
}
persons @0 :List(Person) $json.listAsObject;
}
````
````json
"team" : {
"john" : {"name" : "John Big", "height" : 183.1},
"john2" : {"name" : "John Bigger", "height" : 188.7}
}
````
The annotation $json.listAsObject instructs the json codec to parse and
serialize the annotated array field as json object. By default, the first
struct field is consumed as field name. Could be specialized to use
specific struct field and to not remove the field from struct.
Thoughts? Is this interesting upstream? I am only to brainstorming now. I
may be able to contribute it some time later.
Kind regards
Brano
I think about json.listasObject annotation.
````capnp
using json = using import "/capnp/json .capnp";
struct Team {
struct Person {
id @0 :Text;
name @1 :Text;
height @2 :Float64;
}
persons @0 :List(Person) $json.listAsObject;
}
````
````json
"team" : {
"john" : {"name" : "John Big", "height" : 183.1},
"john2" : {"name" : "John Bigger", "height" : 188.7}
}
````
The annotation $json.listAsObject instructs the json codec to parse and
serialize the annotated array field as json object. By default, the first
struct field is consumed as field name. Could be specialized to use
specific struct field and to not remove the field from struct.
Thoughts? Is this interesting upstream? I am only to brainstorming now. I
may be able to contribute it some time later.
Kind regards
Brano
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.