Kapow36
Posts: 0
Joined: Thu May 23, 2013 4:07 pm

Editing a JSON Array before REST mapping takes place

Hello,
Right now I am trying to work with a web developer to get the REST mapping to work correctly, so far I get JSON Arrays in a format that doesn't work the best (makes for a lot of manual work). Is there anyway to edit the JSON response before mapping?

Kapow36
Posts: 0
Joined: Thu May 23, 2013 4:07 pm

Editing a JSON Array before REST mapping takes place

I'm trying to get it from looking like this...

code
{
"COLUMNS":[
"FAMILYID",
"MEMBERID",
"FAMILY",
"EMAIL",
"FIRSTNAME",
"SPOUSEFIRST",
"ADDRESS",
"CITY",
"STATE",
"ZIP",
"COUNTRY",
"PHONE",
"AREACODE",
"FAX",
"CHILDNAME",
"BIRTHDATE"
],
"DATA":[
[
ID,
ID,
"Last Name",
"Email",
"Someone",
"Someone",
"Address",
"City",
"State",
Zip,
"Country",
phone,
area code,
"fax",
"name",
null
],
]
}
/code

to this...

code
{
"Data":[
{
"FAMILYID" : "ID",
"MEMBERID" : "ID",
"FAMILY" : "Last Name",
"EMAIL" : "Email",
"FIRSTNAME" : "FirstName",
"SPOUSEFIRST" : "Someone",
"ADDRESS" : "Address",
"CITY" : "City",
"STATE" : "State",
"ZIP" : "Zip",
"COUNTRY" : "Country",
"PHONE" : "number",
"AREACODE" : "area code",
"FAX" : "",
"CHILDNAME" : "name",
"BIRTHDATE" : "null"
}
]
}
/code

Kapow36
Posts: 0
Joined: Thu May 23, 2013 4:07 pm

Editing a JSON Array before REST mapping takes place

Ok, so I found
code
var jsonback = {
"__type": "GeoPoint",
"latitude": 10.0,
"longitude": 20.0,
};
return jsonback;
/code

Does this belong in the service complete method then? The docs don't say.

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

Editing a JSON Array before REST mapping takes place

complete callback is called after the mapping is done. To modify the JSON in this fashion -- it's better to do this on the service side, not on the client.

Kapow36
Posts: 0
Joined: Thu May 23, 2013 4:07 pm

Editing a JSON Array before REST mapping takes place

Is there any way to do this App side at all? I know it would be easier to do it server side, but the server side has already been developed in the past.

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

Editing a JSON Array before REST mapping takes place

Your best option is to use a Generic Service -- there you will have complete control over the JSON.

Return to “Issues”