on ‎2014 Feb 28 12:48 PM
Hi,
How can a string be converted to a JSON object in SAPUI5 ?
Example : var mystr = ' [ { name : "Joe", last : "Doe"}, { name : "Jack", last : "Daniel" }]';
How do i convert mystr to a JSON object which can be used in a JSONModel?
$,parseJSON(mystr) or jQuery.parseJSON(myStr) do not seem to exist.
JSONModel.setJSON(mystr) too did not work.
Any pointers ?
regards,
sreeram
Request clarification before answering.
Hi Ben, Chandra, Vladimir,
My mistake. As both Ben and Vladimir have pointed out, the parseJSON expects string with double quotes around the property names.
I came to the wrong conclusion, since the test object could be constructed in Javascript without the quotes. Also, the documentation and editor's choices did not have "parseJSON'.
Now, my code is working.
regards,
sreeram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.