tchart Well-Known Member Licensed User Longtime User Oct 17, 2020 #1 Hi All, I trying to use JSON generator to return a JSON to be used in some javascript code. e.g. {name: "Item 1", type: Tree.FOLDER} However Tree.FOLDER returns as "Tree.FOLDER" which is not working. Is there a way to esacpe this from being quoted? Thanks
Hi All, I trying to use JSON generator to return a JSON to be used in some javascript code. e.g. {name: "Item 1", type: Tree.FOLDER} However Tree.FOLDER returns as "Tree.FOLDER" which is not working. Is there a way to esacpe this from being quoted? Thanks
B Brian Dean Well-Known Member Licensed User Longtime User Oct 17, 2020 #2 A JSON object must contain JSON variables. There are six types : strings; numbers; Booleans; arrays; JSON objects; null. Which of these is Tree.FOLDER? I suspect that it is a variable and it is the content of that variable, probably a string, that you should be putting into the JSON generator. At the moment the JSON generator is trying to help you out by making a best guess. Upvote 0
A JSON object must contain JSON variables. There are six types : strings; numbers; Booleans; arrays; JSON objects; null. Which of these is Tree.FOLDER? I suspect that it is a variable and it is the content of that variable, probably a string, that you should be putting into the JSON generator. At the moment the JSON generator is trying to help you out by making a best guess.
tchart Well-Known Member Licensed User Longtime User Oct 19, 2020 #3 Thanks, Im familar with JSON. In the JavaScript library Im using Tree.FOLDER is an object, which is why I would like to avoid putting it in quotes. As a work around Ive altered the JavaScript library to check a string literal instead of just testing against the Tree.FOLDER object. As per my original question I was just asking if there was a way to add unquoted text in JSON generator. Upvote 0
Thanks, Im familar with JSON. In the JavaScript library Im using Tree.FOLDER is an object, which is why I would like to avoid putting it in quotes. As a work around Ive altered the JavaScript library to check a string literal instead of just testing against the Tree.FOLDER object. As per my original question I was just asking if there was a way to add unquoted text in JSON generator.
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2020 #4 tchart said: Is there a way to esacpe this from being quoted? Click to expand... No. It will be an invalid json. You can replace it yourself after the json string is generated. Code: Copy Dim s As String = JsonString.Replace($""Tree.FOLDER""$, "Tree.FOLDER") Upvote 0
tchart said: Is there a way to esacpe this from being quoted? Click to expand... No. It will be an invalid json. You can replace it yourself after the json string is generated. Code: Copy Dim s As String = JsonString.Replace($""Tree.FOLDER""$, "Tree.FOLDER")
tchart Well-Known Member Licensed User Longtime User Oct 19, 2020 #5 Thanks Erel, I was doing that initially but I have decided to alter the JavaScript library to work with a string. Upvote 0
Thanks Erel, I was doing that initially but I have decided to alter the JavaScript library to work with a string.