Unity3dAzure / AppServicesDemo

Azure App Services demos for Unity
https://www.deadlyfingers.net/tutorial/azure-app-services-for-unity3d
MIT License
27 stars 13 forks source link

(Sort of off topic) How you dealing with REST Services / JSON ? #20

Closed punkouter2021 closed 8 years ago

punkouter2021 commented 8 years ago

The Azure part here is 50% of what I am trying to do. Accessing REST APIs is the other part.

Are you using just the WWW class and some JSON library? I have not been able to find much to get me going in the right direction

deadlyfingers commented 8 years ago

The Mobile Service client implements UnityRestClient library which uses JsonFx plugin to parse JSON data. (The reason why JsonFx plugin is because it runs on all mobile platforms, and its also free.)

More info about the Mobile / App Service REST APIs supported are on the MobileService repro.

punkouter2021 commented 8 years ago

What do you do when you want to use a public REST service. My guess is something like.

  1. Get the REST URLs you need. Call them using the WWW class
  2. Take the XML/JSON results and use a XML->Classes converter so you can use objects
  3. Use a JSON/Xml Serializer to send XML/Json into those classes

Am I right? OR missing anything ?

deadlyfingers commented 8 years ago

Yes, except I use RestRequest instead of Unity WWW class. This might be something to look at again. But the UnityRestClient library has an XML and JSON serializer which uses the JsonFx plugin.

punkouter2021 commented 8 years ago

Ok. So this is what you do internally to call the Mobile Services is REST calls ? So if I wanted to know how to do REST calls I should look at that ? Between being able to call REST and put into objects + use Azure Mobiles Services that should cover everything I need

deadlyfingers commented 8 years ago

@punkouter There are some interesting developments on the Unity Roadmap for REST and JSON (but I need to read through all the docs to see if I can use it for this project)

But as these are new Unity features and this demo project currently uses UnityRestClient & JsonFx plugin as mentioned. So in this case the REST -> JSON -> Object flow is:

  1. Perform a request on the table
  2. Once response arrives the callback is fired
  3. The table data is returned as JSON data and converted to a list of objects using a Model object
punkouter2021 commented 8 years ago

I wonder if it will get to the point no wrapper is needed ?

I do have this working for a simple highscore table. My confusion is more about how to use this with an API app instead of a Mobile App.. A API App that uses code first is what I hope to understand at some point. I don't want any javascript anywhere.

Also if my API app uses swagger then it would be nice if I could generate the client proxy so I don't even have to parse json

deadlyfingers commented 8 years ago

Good idea - be good to add other features of App Services like API Apps. But I really want to finish the feature set available for Mobile Apps (successor to Mobile Services) first. I've just added a wiki page on current features / possible features to be supported - https://github.com/Unity3dAzure/AppServicesDemo/wiki/Azure-App-Service-features-supported-for-Unity3d

deadlyfingers commented 8 years ago

Closing this issue for now - Unity Web Request and Json Utility developments are assigned to issue #22