Hi everyone, i tried make a JSON-LD entity using the org.json package for help me, and the bug appear when try inicializate the JsonUtils of JSON-LD using the method fromString() and the toString() of JSONObject.
When i try mix the context body,the json object and the options in the compact function, the function skip some variables that exist in the body before i call the function.
I put next of this, the example i use to try this fail.
public static void main(String[] args) throws JsonGenerationException, IOException, JsonLdError {
JSONObject json= jsonBasic2();
JSONObject con = new JSONObject("{ \"@context\": [\"https://w3c.github.io/wot/w3c-wot-td-context.jsonld\",\n" +
" \"https://w3c.github.io/wot/w3c-wot-common-context.jsonld\"]}");
Map context = con.toMap();
Object obj = JsonUtils.fromString(json.toString());
JsonLdOptions options = new JsonLdOptions();
Object compact = JsonLdProcessor.compact(obj, context, options);
System.out.println(JsonUtils.toPrettyString(compact));
}
private static JSONObject jsonBasic2() {
// TODO Auto-generated method stub
JSONObject obj= new JSONObject();
obj.put("name", "MyTemperatureThing");
obj.put("@type", new JSONArray()
.put("Thing"));
obj.put("base","coap:///www.example.com:5683/temp/");
return obj;
}
Expected output:
{
"@context": ["http://w3c.github.io/wot/w3c-wot-td-context.jsonld"],
"@type": ["Thing"],
"name": "MyTemperatureThing"
}
Real output:
{
"@type" : "Thing",
"@context" : [ "https://w3c.github.io/wot/w3c-wot-td-context.jsonld", "https://w3c.github.io/wot/w3c-wot-common-context.jsonld" ]
}
Hi everyone, i tried make a JSON-LD entity using the org.json package for help me, and the bug appear when try inicializate the JsonUtils of JSON-LD using the method fromString() and the toString() of JSONObject.
When i try mix the context body,the json object and the options in the compact function, the function skip some variables that exist in the body before i call the function.
I put next of this, the example i use to try this fail.
Expected output:
{ "@context": ["http://w3c.github.io/wot/w3c-wot-td-context.jsonld"], "@type": ["Thing"], "name": "MyTemperatureThing" }Real output:
{ "@type" : "Thing", "@context" : [ "https://w3c.github.io/wot/w3c-wot-td-context.jsonld", "https://w3c.github.io/wot/w3c-wot-common-context.jsonld" ] }