Skip to content

Invalid JSON-LD if Jena defines an "" prefix #141

@fpservant

Description

@fpservant

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");
}

}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions