2016-04-14 15 views
0

私はPHPには新しく、ローカルホストでうまく動作するPHP Webサービスを開発しています。 、コードは、ローカルホストからの解析JSONで正常に動作します文字列がjsonに変換できません

org.json.JSONException: Value script of type java.lang.String cannot be converted to JSONObject` 

私は私のアプリが生きるようにしたいので、私は、ブラウザで byethost17.comに私のPHPファイルをアップロードし、それが正常に戻りJSONに動作しますが、私は私のアプリのショーを実行するとき問題は無料のホスティングウェブサイトからです。解決策とは何ですか?良い無料のWebホスティングサイトはありますか? 100%無料?

org.json.JSONException: Value <html><body><script of type 
    java.lang.String cannot be converted to JSONObject 
at org.json.JSON.typeMismatch(JSON.java:111) 
at org.json.JSONObject.<init>(JSONObject.java:160) 
    at org.json.JSONObject.<init>(JSONObject.java:173) 






     this is result from browser when hit same url 

    {"data":[{"Category": 
{"Category_ID":"3","Category_name":"Camera","Category_image": 
"upload\/images\/7089-2015-07-09.png"}},{"Category": 
{"Category_ID":"9","Category_name":"Cars", 
"Category_image":"upload\/images\/7789-2015-07-09.png"}},{"Category": 
{"Category_ID":"4","Category_name":"Clothes", 
"Category_image":"upload\/images\/9350-2015-07-09.png"}},{"Category": 
{"Category_ID":"1","Category_name":"Computer", 
    "Category_image":"upload\/images\/1843-2015-07-09.png"}},{"Category": 
{"Category_ID":"7","Category_name":"Music", 
"Category_image":"upload\/images\/8666-2015-07-09.png"}},{"Category": 
{"Category_ID":"5","Category_name":"Other", 
"Category_image":"upload\/images\/6260-2015-07-09.png"}},{"Category": 
{"Category_ID":"2","Category_name":"Smartphone", 

"Category_image":"upload\/images\/3025-2015-07-09.png"}},{"Category": 
{"Category_ID":"8","Category_name":"Sports", 

    "Category_image":"upload\/images\/5354-2015-07-09.png"}}, 

{"Category":{"Category_ID":"10","Category_name":"waqas 
Company","Category_image":"upload\/images\/9853-2016-04-11.jpg"}}]} 
+0

WあなたはJSONに変換しようとしていますか? –

+0

オンラインストアの商品データ私はこの問題を私の問題と同じように見つけましたhttp://stackoverflow.com/questions/33439515/problems-in-parse-com-php-hosting –

+0

私に正しいものを与えてくれる無料のホスティングサイトjson ???????? –

答えて

0

あなたはJSONの配列でないJSONオブジェクトで始まるを示しているJSON文字列は、配列にそれを解析しようとする代わりに

0

あなたはページではなく、元のテキストを取得する必要があります。

ソースでは、フリーホストが広告アフィリエイトを配置するためです。

ページ本体で

{"data": "stuff"} 

を取得するのであれば、ソースはこのようなものになるだろう:

<html><head> 
    <script> 
     /** affliate code **/ 
    </script> 
    </head> 
    <body> 
     <span>{"data": "stuff"}</span> 
    </body> 
</html> 

私はあなたが理解してほしい...

(もチェックJSON解析前のページソースの戻り値)

関連する問題