Reputation: 3
I am getting a response from the server while doing soap parsing using Ksoap parser. I want to get specific values from object attributes. I am using a magento method catalogCategoryInfo and now want to get the children property separately.
Here I am getting catalogCategoryInfo:
request = new SoapObject(NAMESPACE, "catalogCategoryInfo");
request.addProperty("sessionId",sessionId );
request.addProperty("categoryId","2" );
env.setOutputSoapObject(request);
androidHttpTransport.call("", env);
result = (JSONObject)env.getResponse();
System.out.println("%%%%%%%%%%%%%%"+result);
and output is:
catalogCategoryInfo{category_id=2; is_active=1; position=1; level=1; parent_id=1; all_children=2,400,407,408,410,402,411,420,421,422,424,425,426,428,430,431,432,433,474,475,526,404,429,444,445,446,447,448,449,450,451,453,454,455,456,457,458,459,460,461,405,465,466,467,468,406,476,478,479,480,481,512,513,514,516,517,518,519,520,521,522,523,524,525,527,528,533,535,537,539,540,544; children=400,402,404,405,406,512,527; created_at=2016-02-04 05:39:36; updated_at=2016-02-06 07:28:28; name=Default Category; url_key=default-category; path=1/2; url_path=/default-category; children_count=71; display_mode=PRODUCTS; is_anchor=0; available_sort_by=ArrayOfString{}; default_sort_by=position; }
Now I want to get only the children=400,402,404,405,406,512,527;
property.
Upvotes: 0
Views: 381
Reputation: 3
I found my solution. we can achieve it by using following code: //fetch category information request = new SoapObject(NAMESPACE, "catalogCategoryInfo");
request.addProperty("sessionId ",sessionId );
request.addProperty("categoryId","2");
env.setOutputSoapObject(request);
androidHttpTransport.call("urn:Magento/catalogCategoryInfo",env);
SoapObject response = (SoapObject) env.getResponse();
Object children = (Object)response.getProperty(6);
Upvotes: 0
Reputation:
Get Values from JSON object using key values 1. First get parent object JSONObject resObj=result.getJSONObject("catalogCategoryInfo"); 2. get values from object, its look not formatted json
children=400,402,404,405,406,512,527
children is key, if you want one by one value ask Backend return as JSON Array.
if children is String
string value=resOnj.getString("children");
else children is int
int value=resOnj.getInt("children");
Upvotes: 1