ramim94
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2019
08:24 AM
JSON key with special Character($)
Hi everyone, I have an API response where one of the keys in the JSON response is a $ sign. for example
Now, when I'm trying to parse this inside a for-each loop,
The error is 'Syntax error: unexpected character $'
is there a way to parse this JSON? Thanks in Advance 🙂
response {
...
category{
$nCat : "something",
$sCat : "some other things"
}
...
}
Now, when I'm trying to parse this inside a for-each loop,
for each video in allVideos
gridposter.category = video.category.$nCat
...
end for
The error is 'Syntax error: unexpected character $'
is there a way to parse this JSON? Thanks in Advance 🙂
4 REPLIES 4
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2019
08:33 AM
Re: JSON key with special Character($)
Prior to parsing, do a string replace for the $.
temp=strreplace(readInternet,"$","z_")
temp=strreplace(readInternet,"$","z_")
Function strReplace(basestr As String,oldsub As String,newsub As String) As String
newstr=""
i=1
While i<=Len(basestr)
x=Instr(i,basestr,oldsub)
If x=0
newstr=newstr+MID(basestr,i)
Exit While
End If
If x>i
newstr=newstr+MID(basestr,i,x-i)
i=x
End If
newstr=newstr+newsub
i=i+Len(oldsub)
End While
Return newstr
End Function
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2019
08:35 AM
Re: JSON key with special Character($)
Or you can probably try
gridposter.category = video.category["$nCat"]
ramim94
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2019
08:49 AM
Re: JSON key with special Character($)
Thanks a lot for the quick response, i was looking through associative array methods and doing
worked for me.
video.category.Lookup("$nCat")
worked for me.
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2019
08:00 AM
Re: JSON key with special Character($)
cool