gpt4 book ai didi

android - 我的项目中的 Json 解析错误

转载 作者:太空宇宙 更新时间:2023-11-03 12:35:15 27 4
gpt4 key购买 nike

我在 android 中开发一个项目,该项目使用 json 从 web 服务获取数据并显示在 ListView 中。

我解析了数据,并在模拟器中运行应用程序时强制关闭。

我做错了什么?更正将不胜感激。

这是我的完整代码

public class AndroidJSONParsingActivity extends ListActivity {

// url to make request
private static String url = "http://example.com/";

// JSON Node names
private static final String TAG_PRODUCT = "Product";
private static final String TAG_ID = "shop_prdt_id";
private static final String TAG_CATID="shop_cat_id";
private static final String TAG_SCATID="shop_scat_id";
private static final String TAG_PRODCODE="shop_prdt_code";
private static final String TAG_TITLE="shop_prdt_title";
private static final String TAG_LISTPRICE = "shop_prdt_listprice";
private static final String TAG_OURPRICE = "shop_prdt_ourprice";
private static final String TAG_YOU = "shop_prdt_yousave";
private static final String TAG_STOCK = "shop_prdt_stock";
private static final String TAG_WEIGHT = "shop_prdt_weight";
private static final String TAG_WEIGHTMEASURE = "shop_prdt_weight_measurement";
private static final String TAG_PRODCOLOR = "shop_prdt_color";
private static final String TAG_SIZE = "shop_prdt_size";
private static final String TAG_SPLDESC = "shop_prdt_spl_description";
private static final String TAG_DESC = "shop_prdt_description";
private static final String TAG_FEATURE="shop_prdt_featured";
private static final String TAG_SEOTITLE="shop_prdt_seo_title";
private static final String TAG_SEODESC="shop_prdt_seo_desc";
private static final String TAG_SEOKEYWORDS="shop_prdt_seo_keywords";
private static final String TAG_IMAGES="shop_prdt_images";
private static final String TAG_CLICKS="shop_prdt_clicks";
private static final String TAG_CREATEDATE="shop_prdt_createdon";
private static final String TAG_UPDATEDATE="shop_prdt_updatedon";
private static final String TAG_STATUS="shop_prdt_status";
// contacts JSONArray
JSONArray product = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Hashmap for ListView
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

// Creating JSON Parser instance
JSONParser jParser = new JSONParser();

// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(url);

try {
// Getting Array of Contacts
product = json.getJSONArray(TAG_PRODUCT);

// looping through All product
for(int i = 0; i < product.length(); i++){
JSONObject c = product.getJSONObject(i);

// Storing each json item in variable
String id = c.getString(TAG_ID);
String catid = c.getString(TAG_CATID);
String Subcatid=c.getString(TAG_SCATID);
String prcode =c.getString(TAG_PRODCODE);
String title = c.getString(TAG_TITLE);
String listprice =c.getString(TAG_LISTPRICE);
String ourprice = c.getString(TAG_OURPRICE);
String you=c.getString(TAG_YOU);
String stock =c.getString(TAG_STOCK);
String weight =c.getString(TAG_WEIGHT);
String weightmes =c.getString(TAG_WEIGHTMEASURE);
String color =c.getString(TAG_PRODCOLOR);
String size =c.getString(TAG_SIZE);
String spldesc =c.getString(TAG_SPLDESC);
String desc =c.getString(TAG_DESC);
String feature =c.getString(TAG_FEATURE);
String seotitle=c.getString(TAG_SEOTITLE);
String seodesc =c.getString(TAG_SEODESC);
String seokeywords =c.getString(TAG_SEOKEYWORDS);
String images =c.getString(TAG_IMAGES);
String clicks =c.getString(TAG_CLICKS);
String createdate =c.getString(TAG_CREATEDATE);
String updatedate =c.getString(TAG_UPDATEDATE);
String status =c.getString(TAG_STATUS);

// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();

// adding each child node to HashMap key => value
map.put(TAG_ID, id);
map.put(TAG_TITLE, title);
map.put(TAG_OURPRICE, ourprice);
map.put(TAG_YOU, you);

// adding HashList to ArrayList
contactList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}


/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.list_item,
new String[] { TAG_TITLE, TAG_OURPRICE, TAG_YOU }, new int[] {
R.id.name, R.id.email, R.id.mobile });

setListAdapter(adapter);

// selecting single ListView item
ListView lv = getListView();

// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String name1 = ((TextView) view.findViewById(R.id.name)).getText().toString();
String ourprice1 = ((TextView) view.findViewById(R.id.email)).getText().toString();
String you1 = ((TextView) view.findViewById(R.id.mobile)).getText().toString();

// Starting new intent
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(TAG_TITLE, name1);
in.putExtra(TAG_OURPRICE, ourprice1);
in.putExtra(TAG_YOU, you1);
startActivity(in);

}
});
}

}

我的json文件

    {
"Product": [
{
"shop_prdt_id": "11",
"shop_cat_id": "3",
"shop_scat_id": "0",
"shop_prdt_code": "06PTPL-01PK",
"shop_prdt_title": "Party Wear Anarkkali Suits",
"shop_prdt_listprice": "44",
"shop_prdt_ourprice": "40",
"shop_prdt_yousave": "4",
"shop_prdt_stock": "20",
"shop_prdt_weight": "17.67",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "3,4,7,8,12,13,14",
"shop_prdt_size": "3,5,11,13",
"shop_prdt_spl_description": "",
"shop_prdt_description": "&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.&lt;/p&gt;\r\n\r\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.&lt;/p&gt;\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "Party Wear Anarkkali Suits",
"shop_prdt_seo_desc": "Party Wear Anarkkali Suits",
"shop_prdt_seo_keywords": "Anarkkali Suits",
"shop_prdt_images": "1",
"shop_prdt_clicks": "13",
"shop_prdt_createdon": "2013-10-29 02:26:08",
"shop_prdt_updatedon": "2013-11-17 17:27:37",
"shop_prdt_status": "1"
},
{
"shop_prdt_id": "8",
"shop_cat_id": "2",
"shop_scat_id": "0",
"shop_prdt_code": "SKCT-28",
"shop_prdt_title": "Pure Silk Cotton",
"shop_prdt_listprice": "150",
"shop_prdt_ourprice": "120",
"shop_prdt_yousave": "30",
"shop_prdt_stock": "30",
"shop_prdt_weight": "35",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "25",
"shop_prdt_size": "",
"shop_prdt_spl_description": "&lt;p&gt;&lt;span class=&quot;fbPhotosPhotoCaption&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:45,&amp;quot;tn&amp;quot;:&amp;quot;*G&amp;quot;}&quot; id=&quot;fbPhotoSnowliftCaption&quot; tabindex=&quot;0&quot;&gt;&lt;span class=&quot;hasCaption&quot;&gt;Women and pink ? Perfect combination ! Beautiful bright pink with vibrant coloured threadwork design on it, for a truly classy feel. For the woman who quietly walks into the room and takes everyone&amp;#39;s breath away&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;\r\n",
"shop_prdt_description": "&lt;p&gt;Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &amp;quot;de Finibus Bonorum et Malorum&amp;quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &amp;quot;Lorem ipsum dolor sit amet..&amp;quot;, comes from a line in section 1.10.32.&lt;/p&gt;\r\n\r\n&lt;p&gt;The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &amp;quot;de Finibus Bonorum et Malorum&amp;quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.&lt;/p&gt;\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "Pure Silk Cotton",
"shop_prdt_seo_desc": "For the woman who quietly walks into the room and takes everyone&#039;s breath away.",
"shop_prdt_seo_keywords": "Pure Silk Cotton, Cotton, Sharani Designs",
"shop_prdt_images": "1",
"shop_prdt_clicks": "13",
"shop_prdt_createdon": "2013-10-09 22:15:05",
"shop_prdt_updatedon": "",
"shop_prdt_status": "1"
},
{
"shop_prdt_id": "7",
"shop_cat_id": "1",
"shop_scat_id": "3",
"shop_prdt_code": "PTD-08GR",
"shop_prdt_title": "House Wears with simple colors",
"shop_prdt_listprice": "15",
"shop_prdt_ourprice": "13.90",
"shop_prdt_yousave": "1.1",
"shop_prdt_stock": "25",
"shop_prdt_weight": "11",
"shop_prdt_weight_measurement": "GRM",
"shop_prdt_color": "3,8,10",
"shop_prdt_size": "1,2,3,5,7,9,11",
"shop_prdt_spl_description": "&lt;p&gt;&amp;nbsp;If you are going to use a passage of Lorem Ipsum, you need to be sure there isn&amp;#39;t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.&lt;/p&gt;\r\n",
"shop_prdt_description": "&lt;p&gt;There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don&amp;#39;t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn&amp;#39;t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.&lt;/p&gt;\r\n\r\n&lt;p&gt;Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &amp;quot;de Finibus Bonorum et Malorum&amp;quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &amp;quot;Lorem ipsum dolor sit amet..&amp;quot;, comes from a line in section 1.10.32.&lt;/p&gt;\r\n\r\n&lt;p&gt;The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &amp;quot;de Finibus Bonorum et Malorum&amp;quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.&lt;/p&gt;\r\n",
"shop_prdt_featured": "1",
"shop_prdt_seo_title": "House Wears with simple colors",
"shop_prdt_seo_desc": "This book is a treatise on the theory of ethics, very popular during the Renaissance",
"shop_prdt_seo_keywords": "Sharani Designs",
"shop_prdt_images": "1",
"shop_prdt_clicks": "39",
"shop_prdt_createdon": "2013-10-09 21:48:51",
"shop_prdt_updatedon": "2013-11-16 23:58:07",
"shop_prdt_status": "1"
}
]
}

洛卡特:

  02-05 05:11:37.413: D/dalvikvm(2110): GC_FOR_ALLOC freed 217K, 9% free 2968K/3260K, paused 26ms, total 28ms
02-05 05:11:37.533: E/JSON Parser(2110): Error parsing data org.json.JSONException: Unterminated object at character 8276 of {
02-05 05:11:37.533: E/JSON Parser(2110): "Product":[
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"11",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"3",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"06PTPL-01PK",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"44",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"40",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"4",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"20",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"17.67",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight_measurement":"GRM",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_color":"3,4,7,8,12,13,14",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_size":"3,5,11,13",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_spl_description":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_description":"&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.&lt;\/p&gt;\r\n\r\n&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur bibendum ornare dolor, quis ullamcorper ligula sodales at. Nulla tellus elit, varius non commodo eget, mattis vel eros. In sed ornare nulla.&lt;\/p&gt;\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_featured":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_title":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_desc":"Party Wear Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_keywords":"Anarkkali Suits",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_images":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_clicks":"13",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_createdon":"2013-10-29 02:26:08",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_updatedon":"2013-11-17 17:27:37",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_status":"1"
02-05 05:11:37.533: E/JSON Parser(2110): },
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"10",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"4",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"LEGG-GR01",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Premium Cotton Leggins",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"15",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"13.90",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"1.1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"75",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"11",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight_measurement":"GRM",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_color":"9,12,23,26,27,28,29,36",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_size":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_spl_description":"&lt;p&gt;&lt;span class=&quot;fbPhotosPhotoCaption&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:45,&amp;quot;tn&amp;quot;:&amp;quot;*G&amp;quot;}&quot; id=&quot;fbPhotoSnowliftCaption&quot; tabindex=&quot;0&quot;&gt;&lt;span class=&quot;hasCaption&quot;&gt;SLIGHT COLOUR VARIATIONS POSSIBLE DUE TO PHOTOGRAPHIC LIMITATIONS.&lt;\/span&gt;&lt;\/span&gt;&lt;\/p&gt;\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_description":"&lt;p&gt;Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of &amp;quot;de Finibus Bonorum et Malorum&amp;quot; (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, &amp;quot;Lorem ipsum dolor sit amet..&amp;quot;, comes from a line in section 1.10.32.&lt;\/p&gt;\r\n\r\n&lt;p&gt;The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from &amp;quot;de Finibus Bonorum et Malorum&amp;quot; by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.&lt;\/p&gt;\r\n",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_featured":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_title":"Premium Cotton Leggins",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_desc":"96% Premium Cotton and 4% Spandex",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_seo_keywords":"Premium Cotton Leggins, cotton, sharani designs",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_images":"1",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_clicks":"84",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_createdon":"2013-10-09 22:23:56",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_updatedon":"",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_status":"1"
02-05 05:11:37.533: E/JSON Parser(2110): },
02-05 05:11:37.533: E/JSON Parser(2110): {
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_id":"9",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_cat_id":"2",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_scat_id":"0",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_code":"SKCT-38",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_title":"Pure Silk Cotton",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_listprice":"195",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_ourprice":"150",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_yousave":"45",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_stock":"34",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight":"110",
02-05 05:11:37.533: E/JSON Parser(2110): "shop_prdt_weight
02-05 05:11:37.543: D/AndroidRuntime(2110): Shutting down VM
02-05 05:11:37.543: W/dalvikvm(2110): threadid=1: thread exiting with uncaught exception (group=0xb4a4ab90)
02-05 05:11:37.573: E/AndroidRuntime(2110): FATAL EXCEPTION: main
02-05 05:11:37.573: E/AndroidRuntime(2110): Process: com.androidhive.jsonparsing, PID: 2110
02-05 05:11:37.573: E/AndroidRuntime(2110): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: java.lang.NullPointerException
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.os.Handler.dispatchMessage(Handler.java:102)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.os.Looper.loop(Looper.java:137)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-05 05:11:37.573: E/AndroidRuntime(2110): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 05:11:37.573: E/AndroidRuntime(2110): at java.lang.reflect.Method.invoke(Method.java:515)
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-05 05:11:37.573: E/AndroidRuntime(2110): at dalvik.system.NativeStart.main(Native Method)
02-05 05:11:37.573: E/AndroidRuntime(2110): Caused by: java.lang.NullPointerException
02-05 05:11:37.573: E/AndroidRuntime(2110): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:73)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.Activity.performCreate(Activity.java:5243)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-05 05:11:37.573: E/AndroidRuntime(2110): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-05 05:11:37.573: E/AndroidRuntime(2110): ... 11 more
02-05 05:11:39.853: I/Process(2110): Sending signal. PID: 2110 SIG: 9
02-05 05:35:06.173: D/AndroidRuntime(2165): Shutting down VM
02-05 05:35:06.173: W/dalvikvm(2165): threadid=1: thread exiting with uncaught exception (group=0xb4a4ab90)
02-05 05:35:06.183: E/AndroidRuntime(2165): FATAL EXCEPTION: main
02-05 05:35:06.183: E/AndroidRuntime(2165): Process: com.androidhive.jsonparsing, PID: 2165
02-05 05:35:06.183: E/AndroidRuntime(2165): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: java.lang.IllegalArgumentException: Host name may not be null
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.access$700(ActivityThread.java:135)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.os.Handler.dispatchMessage(Handler.java:102)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.os.Looper.loop(Looper.java:137)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.main(ActivityThread.java:4998)
02-05 05:35:06.183: E/AndroidRuntime(2165): at java.lang.reflect.Method.invokeNative(Native Method)
02-05 05:35:06.183: E/AndroidRuntime(2165): at java.lang.reflect.Method.invoke(Method.java:515)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-05 05:35:06.183: E/AndroidRuntime(2165): at dalvik.system.NativeStart.main(Native Method)
02-05 05:35:06.183: E/AndroidRuntime(2165): Caused by: java.lang.IllegalArgumentException: Host name may not be null
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.HttpHost.<init>(HttpHost.java:83)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.determineTarget(AbstractHttpClient.java:497)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-05 05:35:06.183: E/AndroidRuntime(2165): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.androidhive.jsonparsing.JSONParser.getJSONFromUrl(JSONParser.java:38)
02-05 05:35:06.183: E/AndroidRuntime(2165): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:69)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.Activity.performCreate(Activity.java:5243)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-05 05:35:06.183: E/AndroidRuntime(2165): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
02-05 05:35:06.183: E/AndroidRuntime(2165): ... 11 more
02-05 05:35:07.913: I/Process(2165): Sending signal. PID: 2165 SIG: 9

最佳答案

您的 JSON 文件附近有错误

"shop_prdt_images": "1""shop_prdt_clicks": "13",

应该是

"shop_prdt_images": "1",
"shop_prdt_clicks": "13",

关于android - 我的项目中的 Json 解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21574177/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com