leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Echo Response Truncated

Okay, I got the JSON validated and can now display the names. But I'm still bogged down with my second question: How to traverse the JSON containing the detail data, find the record, and get the data with
a) 1 RESTService with two JSON objects (myNames and myDetails)
b) 2 RESTServices: with a JSON object placed in each service
Examples would be appreciated.

code{
"myNames" [
{"name": "Name 1","index": 0},
{"name": "Name 2","index": 1}
]
}

{
"myDetails" [
{"name": "Name 1","story":......"},
{"name": "Name 2","story":......"}
]
}
/code

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Echo Response Truncated

You should search online for an example - you should be able to find plenty of examples of how to traverse JSON with JavaScript.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Echo Response Truncated

Yep, I am actually doing that. My problem is how to connect the two JSON objects from Appery REST.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Echo Response Truncated

You can get the entire JSON via service's 'success' event.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Echo Response Truncated

No resolution to this problem. I have the 2 Json data validated and put in RESTservice1 and RESTservice3. I have the following applied:

code<b>On StartPage Restservice1 Success<&#47;b>:
var count = data&#46;pnames&#46;length;
alert("count: " + count); &#47;&#47;Works as expected

<b>On StartPage Restservice3 Success<&#47;b>:
var countb=data&#46;pdetail&#46;length;
alert("detail count: " + countb); &#47;&#47;hangs and gives nothing
/code
Simply, where and how would I connect more than 1 RestServices?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Echo Response Truncated

Hi Leonardo,

Create two services. The first one is for item list. The second one is for selected item content.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Echo Response Truncated

codeCreate two services&#46; The first one is for item list&#46; The second one is for selected item content&#46;/code

Katya, that's exactly what I did, but as shown above cannot access it from the service success, as I thought I would and as was pointed out earlier.

I've been going back and forth for weeks on this seemingly simple thing. Is it possible to know exactly how I can access the data? I've referenced it as "data.pdetail" and also "window.pdetail" all to no avail. How should I reference it?The project called "Opi" is still shared.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Echo Response Truncated

Services for getting content won't help. You also haven't converted XML with content to JSON.
You would need to convert content to JSON and place it in usual JavaScript files where access needed item by array index.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Echo Response Truncated

Katya. Thanks so much for pointing me to JSON. It is very easy to use once the data is validated. (BTW, I converted the XML to JSON, but left it in Echo just for testing and comparison purposes).
In case it might help someone else, this is the process that I used:
code
1&#46; Create a validated JSON
2&#46; Copy it and paste into a new Javascript in Appery
3&#46; Declare the javascript as a variable
4&#46; Access it like a normal js array&#46;
/code

Return to “Issues”