-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ambiguous JSON path when keys include special characters #1
Comments
@abdulmth Thank you for your feedback! What you have found is certainly a problem, but I'm not sure if the solution used here https://github.com/iotaledger/sd-jwt-payload is usable in this context as I need to handle flattened JSON. That is, when I need to call the function {
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
"ciao": [
{"u1": "value1"},
{"u2": "value2"}
]
},
"name": "John Doe"
} but will be: {
"degree.type": "BachelorDegree",
"degree.name": "Bachelor of Science and Arts",
"degree.ciao[0].u1": "value1",
"degree.ciao[1].u2": "value2",
"name": "John Doe"
} The fundamental problem lies in the handling of flattening, which, as implemented, does not handle the possibility that keys may contain the "." character or "[]" characters used as separators during the flattening and unflattening process. Maybe exploring this https://datatracker.ietf.org/doc/html/rfc6901#section-4 could be interesting. Applying the evaluation process used here during flattening and unflattening might be a potential solution, less complicated than JSON paths. What do you think? |
@AlbertoSvg yes, JSON pointer looks great if it can be used. Then the flattening would be using a standard, which is probably necessary. I will look into using it in the |
@AlbertoSvg I wanted to let you know that we decided to use JSON pointer in the |
@abdulmth Thanks for sharing! Glad to hear the JSON pointer worked well for you. I will try to implement it here as soon as possible as well. |
One edge case I came across is on
JwpPresentedBuilder.set_undisclosed
not supporting special characters in JSON.For example, the following is a valid JSON:
But I don't think there is a way to access or deal with the value
ciao.
. Same probably with characters like[..]
when they're included in keys.One way we dealt with this issue in https://github.com/iotaledger/sd-jwt-payload is using a string array. This had its limitations, like not being able to access values inside arrays. Another solution could be by using JSON path, but that might not be straight forward to implement.
The text was updated successfully, but these errors were encountered: