Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
I have a html source as below, how can I parse it easily? can I use JSON to it?
please give some suggestion, thanks a lot!
Code:
<script>
_c=[
[{'1','program1],['2','program2'],['4','program3'],['5','program4'],['6','program5'],['7','program6'],['8','program7'],['9','program8'],['12','program9'}],
[{'1','program1],['2','program2'],['4','program3'],['5','program4'],['6','program5'],['7','program6'],['8','program7'],['9','program8'],['12','program9'}],
[{'1','program1],['2','program2'],['4','program3'],['5','program4'],['6','program5'],['7','program6'],['8','program7'],['9','program8'],['12','program9'}]
]
</script>
 
What is it you want to do?

What have you tried?

Does this actually belong in the iOS programming section?
I use NSURLConnection to download a html source, there are code as above, I want to know if there is a easy way to parse it
 
The posted JavaScript is invalid. It's missing at least one closing quote, and it uses { ) with unnamed values.

Please fix the posted code, or post an actual example from the real HTML.


If you look at the JSON spec, you will see that single quotes (which your example uses) are invalid for JSON. So you can't parse the example posted by using a JSON parser, even if you fixed the problems I listed above. You could translate single-quotes to double-quotes, but without knowing the actual content of the elements, you might be creating another problem.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.