subhalaxmi
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
10:13 PM
ParseJson Error
Hi Guys
I am parsing a json data.I am using Roku OS 7.0
my code :
if (code = 200)
json = ParseJSON(msg.GetString())
But it throws ParseJson:Unknown Identifier Error. How can I solve this guys. I need urgent response.
I am parsing a json data.I am using Roku OS 7.0
my code :
if (code = 200)
json = ParseJSON(msg.GetString())
But it throws ParseJson:Unknown Identifier Error. How can I solve this guys. I need urgent response.
16 REPLIES 16

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
10:26 PM
Re: ParseJson Error
Without sharing the json string you're trying to parse, it's impossible to help. Based on the message, it sounds like the json is invalid.
You could try a tool like this to validate your json, and identify the issue: http://jsonlint.com/
You could try a tool like this to validate your json, and identify the issue: http://jsonlint.com/
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
subhalaxmi
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
10:45 PM
Re: ParseJson Error
Json is valid.I have tested it.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
10:51 PM
Re: ParseJson Error
Can you share the URL you're pulling the JSON from, so we can investigate? Again, we can't really help without knowing what "msg.GetString()" returns.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
10:59 PM
Re: ParseJson Error
Maybe you don't have quote characters around an object key:
Or it could be some other problem with your Json. But like TheEndless says, without seeing the Json string there's not much help we can offer.
' GOOD ...
jsonString = "{" + Chr (34) + "a" + Chr (34) + ": 42}"
json = parseJson (jsonString)
Print json
' BAD ...
jsonString = "{a: 42}"
json = parseJson (jsonString)
Print json
a: 42
BRIGHTSCRIPT: ERROR: ParseJSON: Unknown identifier 'a: 42}': pkg:/source/Main.brs(18)
invalid
Or it could be some other problem with your Json. But like TheEndless says, without seeing the Json string there's not much help we can offer.
subhalaxmi
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
11:01 PM
Re: ParseJson Error
Sorry I cannot share the json url.But I can assure you that json is valid in rest client.And I am using the follwoing code to parse.
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
print msg.GetString()
json = ParseJSON(msg.GetString())
return json.itemCount.ToInt()
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
when I am printing msg.GetString() it is printing all data which is in valid json format.But in next line json = ParseJSON(msg.GetString()) it is breaking after parsing some codes.
I am bugging since 4 hours.I ccannot be able to find out issue.Can you please help me.
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
print msg.GetString()
json = ParseJSON(msg.GetString())
return json.itemCount.ToInt()
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
when I am printing msg.GetString() it is printing all data which is in valid json format.But in next line json = ParseJSON(msg.GetString()) it is breaking after parsing some codes.
I am bugging since 4 hours.I ccannot be able to find out issue.Can you please help me.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
11:08 PM
Re: ParseJson Error
"subhalaxmi" wrote:
I ccannot be able to find out issue.Can you please help me.
I honestly can't without knowing what you're trying to parse. Can you share it via PM?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
subhalaxmi
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
11:18 PM
Re: ParseJson Error
This is my json response.
{
"status": 200,
"msg": "OK",
"list": [{
"0": "0",
"id": "1021",
"ispresent": 0
}, {
"0": "1",
"id": "1022",
"ispresent": 0
}, {
"0": "2",
"id": "1023",
"ispresent": 0
}, {
"0": "3",
"id": "1024",
"ispresent": 0
}, {
"0": "4",
"id": "1025",
"ispresent": 0
}, {
"0": "5",
"id": "1026",
"ispresent": 0
}, {
"0": "6",
"id": "1027",
"ispresent": 0
}, {
"0": "7",
"id": "1028",
"ispresent": 0
}, {
"0": "8",
"id": "1029",
"ispresent": 0
}, {
"0": "9",
"id": "1030",
"ispresent": 0
}],
"orderby": "",
"count": "10",
"limit": 10
}
Guys help me
{
"status": 200,
"msg": "OK",
"list": [{
"0": "0",
"id": "1021",
"ispresent": 0
}, {
"0": "1",
"id": "1022",
"ispresent": 0
}, {
"0": "2",
"id": "1023",
"ispresent": 0
}, {
"0": "3",
"id": "1024",
"ispresent": 0
}, {
"0": "4",
"id": "1025",
"ispresent": 0
}, {
"0": "5",
"id": "1026",
"ispresent": 0
}, {
"0": "6",
"id": "1027",
"ispresent": 0
}, {
"0": "7",
"id": "1028",
"ispresent": 0
}, {
"0": "8",
"id": "1029",
"ispresent": 0
}, {
"0": "9",
"id": "1030",
"ispresent": 0
}],
"orderby": "",
"count": "10",
"limit": 10
}
Guys help me
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2015
11:30 PM
Re: ParseJson Error
It parses correctly on my Roku 2XS running 7.0 build 9037.
All I can think of is that there may be extraneous unprintable characters (e.g. cr/lf) in your Json response.
Also, what is the character encoding of your response?
All I can think of is that there may be extraneous unprintable characters (e.g. cr/lf) in your Json response.
Also, what is the character encoding of your response?
subhalaxmi
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2015
12:33 AM
Re: ParseJson Error
Can you please post your parsing code you use to get response.
Function get_playlist() as object
request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetMessagePort(port)
request.SetUrl("http://www.khanacademy.org/api/v1/playlists")
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
playlist = CreateObject("roArray", 10, true)
json = ParseJSON(msg.GetString())
for each kind in json
topic = {
ID: kind.id
Title: kind.standalone_title
}
playlist.push(topic)
end for
return playlist
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
return invalid
End Function
I am using this kind of code which needs no encoding.
Function get_playlist() as object
request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetMessagePort(port)
request.SetUrl("http://www.khanacademy.org/api/v1/playlists")
if (request.AsyncGetToString())
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
playlist = CreateObject("roArray", 10, true)
json = ParseJSON(msg.GetString())
for each kind in json
topic = {
ID: kind.id
Title: kind.standalone_title
}
playlist.push(topic)
end for
return playlist
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
endif
return invalid
End Function
I am using this kind of code which needs no encoding.