I have a URLConnection that has an Event Handler - ContentReceived. I am attempting to parse the returned string ‘Content’ into a Variant named json and I have attempted to do this as followings with this error
// In the returned JSON, you will see it is an array
Dim json As Variant
json = ParseJSON(Content)
This errors as lexical error: invalid bytes in UTF8 string.
I have also tried this without success.
// Looking at the returned JSON, you can see it is an array
Dim json As Auto
json = Xojo.Data.ParseJSON(content.ToText)
and this
// Looking at the returned JSON, you can see it is an array
Dim json() As Auto
json = Xojo.Data.ParseJSON(content.ToText)
Both error with The data could not be converted to text with this encoding.
Here is the returned String I am attempting to put into JSON
[{“id”:“2”,“login_name”:“aperson”,“passwordSalt”:“jKAfSvcs10awESaqvsME”,“passwordHash”:“\r\u0003�/R>~�7��m#�c��\u001C���V��A!�W�b�S”,“privilege”:“Super”,“company”:“”,“db_to_use”:“somecounty”,“db_to_use_username”:“somecounty”,“db_to_use_password”:“anotherpassword”,“table_to_use”:“tabletouse”,“table_to_use_username”:“ausername”,“apassword”:“a1password”,“MyDBPersonalHost”:“10.8.32.12”,“MyDBDataHost”:“10.8.32.12”,“sql_str_to_use”:“SELECT * FROM tabletouse JOIN Contact_Info ON tabletouse.VRCNUM = Contact_Info.VRCNUM JOIN Lawn_Signs_2019 ON tabletouse.VRCNUM = Lawn_Signs_2019.VRCNUM JOIN Contributions_2019 ON tabletouse.VRCNUM = Contributions_2019.VRCNUM WHERE (Town_Code = ‘060’) Or (note LIKE ‘%supporter%’ ) ORDER BY (Town_Code+0) ASC, (Election_District+0) ASC, Street ASC, (House_Number+0) ASC”,“LD”:“15”,“ED”:“37”,“Party”:“party”,“Table_Year”:“2021”,“City”:“acity”,“TownCode”:“095”}]
I found threads where I need to change this Dim json As Variant to this Dim json As Variant or this Dim json As Auto but each fail.
I had this working on 2019r1.2 with that rerun Content was xojo.CoreMemoryBlock but do not see how to make this work on 2021r2 when content is returned as String. I need to get this into JSON so the
response can be read appropriately as I follow this up with the following
Our_Table = Xojo.Core.Dictionary(json(0)).Value("table_to_use")