serialize/deserialize JSON in mono touch/droid - json

Is there a cross platform way to serialize/deserialize JSON in mono touch/droid, without using a 3rd party library like Newtonsoft.Json?
Do I have to have an object per platform?

Both MonoTouch and Mono for Android ships with a System.Json.dll assembly which provides the same feature set you can find in Silverlight (and .NET 4.5).
Note: both MT and M4A profiles were based on Silverlight and enhanced over time to cover more API.

Related

Alternatives to Newtonsoft.JSON for Monodroid

We currently use Newtonsoft.JSON for notation and serialization/de-serialization of JSON objects in our C# based projects (along the lines of the following), which we also need to share with an application which has been written using Xamarin MonoDroid
[JsonProperty("type")]
public string theType { get; set; }
....
JsonConvert.DeserializeObject<List<OurModel>>(jsonString);
However, the Newtonsoft.JSON isn't compatible with Mono
Presumably, there is an easy solution to handling JSON data BOTH within the C# environment as well as Monodroid? Ideally, so that we can have a common class that is shared between the two projects?
As listed on the Json.NET homepage, "Json.NET supports Windows, Windows Store, Windows Phone, Mono, and Xamarin."
Newtonsoft is the company that makes Json.NET - so the namespace that the library uses is "Newtonsoft.Json". They are both referring to the same library.
I have successfully used Json.NET in my Xamarin.Android applications.
If you aren't sure where to get a copy of the library that will work with your Xamarin.Android application, try using NuGet

Is there a way to parse JSON data returned from a web service in actionscript without using as3corelib

I am working on a method that needs to parse the JSON response. I looked around and people use JSON.decode() in the as3corelib. But I was wondering if there was another way to do this without having to install any other libraries like this (as3corelib). Like a native json method that comes with the actionscript libraries.
Take a look at the top level JSON class, available since Flash Player 11, AIR 3.0.
The JSON class lets applications import and export data using JavaScript Object Notation (JSON) format.
Why do you have a problem with using an external library?
There is no such thing as an installation required, you just download it.

How to deserialize JSON in a Windows 8 App seamlessly

The Web API Client Library NuGet Packag brings in JSON.NET and some handy extension methods for deserializing JSON like so:
response.Content.ReadAsAsync<IEnumerable<Product>>().Result
But this package is not compatible with Windows 8 App projects. How can I deserialize my JSON objects in the same generic way without this NuGet package?
What do you mean by saying "not compatible with Win 8"?
The Microsoft.AspNet.WebApi.Client has been developed to support Win8.
Install-Package Microsoft.AspNet.WebApi.Client
Install just this package, not entire Web API.
You can see the release notes here, in the blog post by Henrik Frystyk Nielsen - http://blogs.msdn.com/b/henrikn/archive/2012/08/15/asp-net-web-api-released-and-a-preview-of-what-s-next.aspx
The Microsoft ASP.NET Web API Client Libraries package adds support for formatting
content negotiation to System.Net.Http when writing Windows Store Apps.
It includes support for JSON, XML, form URL encoded data, as well as MIME multipart.
This package requires Visual Studio 2012 and Windows 8.
There are at least 2 JSON serializers available for Windows Store apps:
DataContractJsonSerializer is a part of .NET framework.
Json.NET is supported as well. You can add it into a Windows Store app project if you install just this package: Install-Package Newtonsoft.Json
What exactly are you refering to with "deserialize my JSON objects in the same generic way"?

reading JSON on Blackberry OS pre 6.0

I am trying to implement web services within an app, and the response of the web serivce is in JSON. How is it possible to parse simple json without net_rim_json_org module of BBOS 6.0?
For pre-6 BB OS people use JSON ME lib.

rpc lib for blackberry / j2me ( json / xml / * )

I'm trying to setup an rpc server so that a blackberry mobile app can make calls to it. Thought of trying out json first.
I've setup a working server side impl using http://jsonrpcphp.org/ .
Couldn't find any direct libs for blackberry/j2me. android-json-rpc looked interesting, but the blackberry SDK complains
"The type java.net.URI cannot be resolved. It is indirectly referenced from required .class files" at this line
HttpPost request = new HttpPost(serviceUri);
I'm using v4.1 of apache http core and client to make android-json-rpc work.
Looks like the URI class isn't bundled with the j2me/blackberry standard lib.
Is there a quick and dirty way to get rpc working on blackberry ? I don't mind xml or any thing else for the encoding, http is the transport I'm interested in.
BlackBerry 6 has built-in the JSON parser and some better APIs for making HTTP requests. Prior to that, though, you have to compile the JSON parser into your app and use the Java ME HttpConnection class to make and get the HTTP requests. So it depends what version you're targeting.
If you are targeting to < BB OS 6.0 devices.
You can also use org.json.me lib in your app.
Here is the sample named Implementing JSON in your application. It's very simple to use.
Good luck