I need some help. I want to know how to get data from a JSON response. I want to make the objectId of the user, their username. But I don't know how to do this. I am also using Parse.
Thanks for the help. That was dummy data, so it will be changed. With this post that you gave me, will I be able to make the objectId that you see at the bottom the end part of the url like this:
local data ={
username ="hex",
password ="ahex3z",
firstName ="Al",
lastName ="Hec",
email ="alh1@hotmail.com"}local body = Json.Encode(data)local user = objectId -- I want user to be the objectId from the response of the Json. How would I get the objectId you see in the picture in my last post?-- Call load the urllocal url = baseUrl .. "/1/users" .. user --This is what I want it to look like.local urlLoader = UrlLoader.new(url, UrlLoader.POST, headers, body)
Thanks hopefully you can help me with this! -Landon
Maybe I'm not sure what you're asking, but if you have an ID in the JSON object, I don't see why you couldn't retrieve it and add it on to the end of your URL.
1) You need to make sure you have json library added to decode the data By looking at your example, you'd probably need to use
local data = Json.Decode(event.data)--and not--json.decode(event.data)
2) put print(event.data) statement before decoding to make sure you receive correct data 3) Do you really can send body data as json encoded string? Just curious haven't tried that
It doesn't even give me an error. It just closes the player and puts me back on the homescreen. Also, would you like me to add the project file so you can take a look at what's going on?
Here's a simple test attached that works. There may be complications if you're trying to use Parse etc. You need to make sure you're getting json data back and how it's being named.
I haven't added one myself, I had experimented with one @ndoss was nice enough to have added himself (Kinvey). But basically you're able to define the API in a text file, you could probably look at Kinvey and others that are already defined and use Parse's API documentation to define the functions you need. It shouldn't be too bad since you will probably only need a handful of actual API calls I would assume.
Comments
Mentions reading JSON using: http://json.luaforge.net/
Also, just in case it wasn't dummy data, your screen shows password information.
Thanks for the help. That was dummy data, so it will be changed. With this post that you gave me, will I be able to make the objectId that you see at the bottom the end part of the url like this:
-Landon
Lead Coder and Designer
How would I retrieve it?
Thanks.
-Landon
Lead Coder and Designer
That didn't work, it made the player crash
Would you like me to attach the project file to allow you to see whats going on?
Thanks.
-Landon
Lead Coder and Designer
1) You need to make sure you have json library added to decode the data
By looking at your example, you'd probably need to use
3) Do you really can send body data as json encoded string? Just curious haven't tried that
It doesn't even give me an error. It just closes the player and puts me back on the homescreen. Also, would you like me to add the project file so you can take a look at what's going on?
I'm also using Parse, if that helps
Thanks.
-Landon
Lead Coder and Designer
http://www.giderosmobile.com/forum/discussion/1069/kinvey-firebase-added-to-gideros-rest-api-library
Thanks for the test project. I won't be able test it until I get home from school today at 4 PM EST.
Also, how would I add Parse's API to the library stated above?
Sorry about asking these questions, I just don't really understand fully the server side of apps.
Thanks again!
-Landon
Lead Coder and Designer