Author: dajobe
Date: Thu Jan 17 08:10:03 2008
New Revision: 13613

URL: http://svn.librdf.org/view?rev=3D13613&view=3Drev
Log:
Added JSON serializing support.  raptor_json_writer class for formatting JS=
ON.  json-r and json-t serializations based on http://n2.talis.com/wiki/RDF=
_JSON_Specification

Added:
    raptor/trunk/src/raptor_json_writer.c   (with props)
    raptor/trunk/src/raptor_serialize_json.c   (with props)
Modified:
    raptor/trunk/configure.ac
    raptor/trunk/src/Makefile.am
    raptor/trunk/src/raptor_internal.h
    raptor/trunk/src/raptor_serialize.c

Modified: raptor/trunk/configure.ac
URL: http://svn.librdf.org/view/raptor/trunk/configure.ac?rev=3D13613&r1=3D=
13612&r2=3D13613&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- raptor/trunk/configure.ac (original)
+++ raptor/trunk/configure.ac Thu Jan 17 08:10:03 2008
@@ -845,8 +845,9 @@
 rss_1_0_serializer=3Dno
 atom_serializer=3Dno
 dot_serializer=3Dno
-
-rdf_serializers_available=3D"rdfxml rdfxml-abbrev turtle ntriples rss-1.0 =
dot"
+json_serializer=3Dno
+
+rdf_serializers_available=3D"rdfxml rdfxml-abbrev turtle ntriples rss-1.0 =
dot json"
 if test "$USE_MAINTAINER_MODE" =3D yes; then
   rdf_serializers_available=3D"$rdf_serializers_available atom"
 fi
@@ -861,6 +862,7 @@
   AC_DEFINE(RAPTOR_SERIALIZER_RSS_1_0, 1, [Building RSS 1.0 serializer])
   AC_DEFINE(RAPTOR_SERIALIZER_ATOM, 1, [Building Atom 1.0 serializer])
   AC_DEFINE(RAPTOR_SERIALIZER_DOT, 1, [Building GraphViz DOT serializer])
+  AC_DEFINE(RAPTOR_SERIALIZER_JSON, 1, [Building JSON serializer])
 fi
 =

 AC_MSG_CHECKING(RDF serializers required)
@@ -890,6 +892,7 @@
 AM_CONDITIONAL(RAPTOR_SERIALIZER_TURTLE, test $turtle_serializer =3D yes)
 AM_CONDITIONAL(RAPTOR_SERIALIZER_RSS_1_0, test $rss_1_0_serializer =3D yes)
 AM_CONDITIONAL(RAPTOR_SERIALIZER_DOT, test $dot_serializer =3D yes)
+AM_CONDITIONAL(RAPTOR_SERIALIZER_JSON, test $json_serializer =3D yes)
 =

 AM_CONDITIONAL(RAPTOR_RSS_COMMON, test $rss_1_0_serializer =3D yes -o $rss=
_parser =3D yes)
 =


Modified: raptor/trunk/src/Makefile.am
URL: http://svn.librdf.org/view/raptor/trunk/src/Makefile.am?rev=3D13613&r1=
=3D13612&r2=3D13613&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- raptor/trunk/src/Makefile.am (original)
+++ raptor/trunk/src/Makefile.am Thu Jan 17 08:10:03 2008
@@ -76,7 +76,8 @@
 raptor_identifier.c \
 raptor_sequence.c raptor_stringbuffer.c raptor_iostream.c \
 raptor_xml.c raptor_xml_writer.c raptor_set.c turtle_common.c \
-raptor_turtle_writer.c raptor_xsd.c raptor_avltree.c snprintf.c
+raptor_turtle_writer.c raptor_xsd.c raptor_avltree.c snprintf.c \
+raptor_json_writer.c
 if RAPTOR_PARSER_RDFXML
 if RAPTOR_XML_LIBXML
 libraptor_la_SOURCES +=3D raptor_libxml.c
@@ -140,6 +141,9 @@
 endif
 if RAPTOR_SERIALIZER_DOT
 libraptor_la_SOURCES +=3D raptor_serialize_dot.c
+endif
+if RAPTOR_SERIALIZER_JSON
+libraptor_la_SOURCES +=3D raptor_serialize_json.c
 endif
 if RAPTOR_NFC_CHECK
 libraptor_la_SOURCES +=3D raptor_nfc_data.c raptor_nfc.c raptor_nfc.h

Modified: raptor/trunk/src/raptor_internal.h
URL: http://svn.librdf.org/view/raptor/trunk/src/raptor_internal.h?rev=3D13=
613&r1=3D13612&r2=3D13613&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- raptor/trunk/src/raptor_internal.h (original)
+++ raptor/trunk/src/raptor_internal.h Thu Jan 17 08:10:03 2008
@@ -730,6 +730,9 @@
 /* raptor_serialize_turtle.c */  =

 int raptor_init_serializer_turtle(void);
 =

+/* raptor_serialize_json.c */  =

+int raptor_init_serializer_json(void);
+
 /* raptor_utf8.c */
 int raptor_unicode_is_namestartchar(raptor_unichar c);
 int raptor_unicode_is_namechar(raptor_unichar c);
@@ -1132,6 +1135,28 @@
 int raptor_turtle_writer_get_feature(raptor_turtle_writer *turtle_writer, =
raptor_feature feature);
 const unsigned char *raptor_turtle_writer_get_feature_string(raptor_turtle=
_writer *turtle_writer, raptor_feature feature);
 =

+
+/**
+ * raptor_json_writer:
+ *
+ * Raptor JSON Writer class
+ */
+typedef struct raptor_json_writer_s raptor_json_writer;
+
+/* raptor_json_writer.c */
+raptor_json_writer* raptor_new_json_writer(raptor_uri* base_uri, const rap=
tor_uri_handler *uri_handler, void *uri_context, raptor_iostream* iostr, ra=
ptor_simple_message_handler error_handler, void *error_data);
+void raptor_free_json_writer(raptor_json_writer* json_writer);
+
+int raptor_json_writer_newline(raptor_json_writer* json_writer);
+int raptor_json_writer_key_value(raptor_json_writer* json_writer, const ch=
ar* key, size_t key_len, const char* value, size_t value_len);
+int raptor_json_writer_start_block(raptor_json_writer* json_writer, char c=
);
+int raptor_json_writer_end_block(raptor_json_writer* json_writer, char c);
+int raptor_json_writer_literal_object(raptor_json_writer* json_writer, uns=
igned char* s, unsigned char* lang, raptor_uri* datatype, const char* key, =
const char* type_key);
+int raptor_json_writer_blank_object(raptor_json_writer* json_writer, const=
 char* blank);
+int raptor_json_writer_uri_object(raptor_json_writer* json_writer, raptor_=
uri* uri);
+int raptor_json_writer_key_uri_value(raptor_json_writer* json_writer, cons=
t char* key, size_t key_len, raptor_uri* uri);
+
+
 /* snprintf.c */
 char* raptor_format_float(char *buffer, size_t *currlen, size_t maxlen, do=
uble fvalue, unsigned int min, unsigned int max, int flags);
 =


Modified: raptor/trunk/src/raptor_serialize.c
URL: http://svn.librdf.org/view/raptor/trunk/src/raptor_serialize.c?rev=3D1=
3613&r1=3D13612&r2=3D13613&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- raptor/trunk/src/raptor_serialize.c (original)
+++ raptor/trunk/src/raptor_serialize.c Thu Jan 17 08:10:03 2008
@@ -119,6 +119,10 @@
 =

 #ifdef RAPTOR_SERIALIZER_DOT
   rc+=3D raptor_init_serializer_dot() !=3D 0;
+#endif
+
+#ifdef RAPTOR_SERIALIZER_JSON
+  rc+=3D raptor_init_serializer_json() !=3D 0;
 #endif
 =

   return rc;


_______________________________________________
redland-commits mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-commits

Reply via email to