-
Notifications
You must be signed in to change notification settings - Fork 152
Invalid JSON-LD if Jena defines an "" prefix #141
Description
if a prefix is set to "", we get an output that is not correct JSON-LD
(according to the JSON-LD playground: "Invalid JSON-LD syntax; a term cannot be an empty string.")
Here a small program using Jena that illustrates the problem. It creates a model and outputs it in JSON-LD. Jena's output in turtle is :
@Prefix : http://www.a.com/foo/ .
:s :p :o .
package sometests;
import org.junit.Test;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
public class JsonLDWriterTest {
@test
public final void test3() {
Model m = ModelFactory.createDefaultModel();
String url = "http://www.a.com/foo/";
Resource s = m.createResource(url + "s");
Property p = m.createProperty(url + "p");
Resource o = m.createResource(url + "o");
m.add(s,p,o);
m.setNsPrefix("",url);
m.write(System.out, "JSON-LD");
}
}