You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by GitBox <gi...@apache.org> on 2018/12/13 11:58:48 UTC
[GitHub] Akayeshmantha opened a new pull request #34: Adding more samples on
rdf serializer and adding clear comments
Akayeshmantha opened a new pull request #34: Adding more samples on rdf serializer and adding clear comments
URL: https://github.com/apache/juneau/pull/34
@jamesbognar added more examples on rdf.And what I see on the http://juneau.apache.org/#marshall.html web page rdf samples seems to be deprecated.Do we need to refactor them.
RDF samples in marshall.html which seems to be not working with current snapshots on marshall-rdf module.
```
// A simple bean
public class Person {
public String name = "John Smith";
public int age = 21;
}
// Serialize a bean to JSON, XML, or HTML
Person p = new Person();
// Produces:
// <rdf:RDF
// xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
// xmlns:jp="http://www.apache.org/juneaubp/"
// xmlns:j="http://www.apache.org/juneau/">
// <rdf:Description>
// <jp:name>John Smith</jp:name>
// <jp:age>21</jp:age>
// </rdf:Description>
// </rdf:RDF>
String rdfXml = RdfSerializer.DEFAULT_XMLABBREV.serialize(p);
// Produces:
// @prefix jp: <http://www.apache.org/juneaubp/> .
// @prefix j: <http://www.apache.org/juneau/> .
// [] jp:age "21" ;
// jp:name "John Smith" .
String rdfN3 = RdfSerializer.DEFAULT_N3.serialize(p);
// Produces:
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/name> "John Smith" .
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/age> "21" .
String rdfNTriple = RdfSerializer.DEFAULT_NTRIPLE.serialize(p);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services