RTSol
asked on
Parsing json
Hi,
I have a service call in my application which returns jsaon data. The call is like so:
The service returns this:
There obviously is something wrong because it is not working. Please help me.
Best regards
RTSol
I have a service call in my application which returns jsaon data. The call is like so:
$.ajax({
type: "GET",
dataType: "json",
url: 'http://rest.smartdoc.se/api/users/' + username + '/' + password,
success: function (Data) {
var obj = $.parseJSON(Data);
alert(obj.FullName);
}
});
The service returns this:
{"Data":[{"FullName":"Doesn't exist","username":"sdf","password":"sdf"}],"Errors":null}
There obviously is something wrong because it is not working. Please help me.
Best regards
RTSol
ASKER
Hi,
The application is running on a smartphone. I need to provide the complete url to the service which is running on a web server. The call to the service works fine and it returns the desired json. My problem is just to parse it.
-RTSol
The application is running on a smartphone. I need to provide the complete url to the service which is running on a web server. The call to the service works fine and it returns the desired json. My problem is just to parse it.
-RTSol
Look at your JSON, you probably need this:
var obj = $.parseJSON(Data);
alert(obj.Data.FullName);
var obj = $.parseJSON(Data);
alert(obj.Data.FullName);
Well... I looked at your code and really bad is this line:
'http://rest.smartdoc.se/api/users/' + username + '/' + password
You're passing username and password in clear text and not even https?
And I hope you're not doing this for each request...
'http://rest.smartdoc.se/api/users/' + username + '/' + password
You're passing username and password in clear text and not even https?
And I hope you're not doing this for each request...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot - that is what I needed.
url: 'http://rest.smartdoc.se/api/users/' + username + '/' + password,
and not :
url: '/api/users/' + username + '/' + password,