In my current project, I have to read a JavaScript file from the Internet and extract an object from it. The variable may change from time to time, so I should read it, and not hardcode it into my Android application.
Let's say I want to extract the following variable (and after that parse the string using JSONObject, which is trivial):
var abc.xyz = { "a": {"one", "two", "three"}, "b": {"four", "five"} }
I have a problem with this. Should I implement some kind of scanner that looks like a compiler, only to search for a name and get its value, or is there some existing tool that I can use?
The JavaScript file is not as simple as this example. It contains a lot of other code. Therefore simple new JSONObject() or something will not do.
source share