Possible Duplicate:
How to parse JSON in Android
I am writing an Android app where I’m getting a .js (JavaScript) file from a url and I want to read its contents. Is there any way to convert this file to a JSONArray or JSONObject? Or a direct way to parse the .js file itself?
If you mean can you create a data structure out of raw JavaScript, then no.
You can’t convert a string of arbitrary JavaScript to JSON except in the degenerate sense that the entire string is a valid JSON item of type ‘string’. This is because the syntax of JS covers a much larger domain than JSON. For example, what kind of JSON structure would you expect to represent the following JS?
If your intent is to traverse the JS and pull data structures out of it, you’re probably going to need something like a full JavaScript parsing engine.
If on the other hand you’ve phrased the question badly and the ‘.js’ file you’re fetching is really a JSON file, then the question is answered in the marked duplicate.