Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boolean value from store being changed in jsonLD serialization #619

Open
MuhammadShafaatKhan13 opened this issue Apr 19, 2023 · 4 comments

Comments

@MuhammadShafaatKhan13
Copy link

MuhammadShafaatKhan13 commented Apr 19, 2023

my store is:
{ "termType": "Graph", "classOrder": 4, "value": "", "statements": [{ "subject": { "termType": "BlankNode", "classOrder": 6, "value": "n0", "isBlank": 1, "isVar": 1 }, "predicate": { "termType": "NamedNode", "classOrder": 5, "value": "https://w3id.org/tern/ontologies/tern/hasSimpleValue" }, "object": { "termType": "Literal", "classOrder": 1, "value": "true", "datatype": { "termType": "NamedNode", "classOrder": 5, "value": "http://www.w3.org/2001/XMLSchema#boolean" }, "isVar": 0, "language": "" }, "graph": { "termType": "NamedNode", "classOrder": 5, "value": "http://graph-species-obs-for-entry-0-of-bird_survey_observation-number-0" } }], "constraints": [], "initBindings": [], "optional": [], "isVar": 0, "rdfFactory": { "supports": { "COLLECTIONS": true, "DEFAULT_GRAPH_TYPE": false, "EQUALS_METHOD": true, "IDENTITY": false, "ID": true, "REVERSIBLE_ID": false, "VARIABLE_TYPE": true } }, "namespaces": {}, "classActions": {}, "propertyActions": { "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>": [null] }, "redirections": [], "aliases": [], "HTTPRedirects": [], "subjectIndex": [], "predicateIndex": [], "objectIndex": [], "whyIndex": [], "index": [ [], [], [], [] ], "features": [] }

But through $rdf.serialize(null, testStore2, null, 'application/ld+json') I am getting following jsonLD object which has hasSimpleValue as false, where as store has it as true.

JSON-LD object:
{ "@context": { "tern": "https://w3id.org/tern/ontologies/tern/" }, "tern:hasSimpleValue": false }

@bourgeoa
Copy link
Contributor

Thanks for reporting
Can you give some more information :

  • version of app, server, rdflib
  • source object

@MuhammadShafaatKhan13
Copy link
Author

Thanks for responding.

rdflib version is 2.2.32, node version is 19.9.0

Below is the code for creating the store and getting jsonld object from it.

var testStore2 = $rdf.graph()
let playBackUsedBnode = $rdf.blankNode()
testStore2.add(playBackUsedBnode, $rdf.sym('https://w3id.org/tern/ontologies/tern/hasSimpleValue'), $rdf.lit(true, '', 'http://www.w3.org/2001/XMLSchema#boolean'))
 $rdf.serialize(null, testStore2, null, 'application/ld+json')

@bourgeoa
Copy link
Contributor

bourgeoa commented Apr 20, 2023

This is not a jsonld issues. Samething arise with text/turtle.

There are already some issues related to boolean value issues.
Apparently the only way to get true is to set the value to 1

  • with explicit http://www.w3.org/2001/XMLSchema#boolean using true, false or 0 all return false
    Apparently the only way to get true is to set the value to 1
   lit(1, 'http://www.w3.org/2001/XMLSchema#boolean'),
  • without it is OK
  lit(true) => true
  lit(false) => false

@bourgeoa
Copy link
Contributor

#604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants