Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979412
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:10:01+00:00 2026-05-20T05:10:01+00:00

there are various ressources on the web explaining how to serialize some C# object

  • 0

there are various ressources on the web explaining how to serialize some C# object to a JSON string. I have been unable to get any of them to work with MonoTouch 3.2.4 though.

Alternatives I came across:

  • the System.Json Namespace
    I am already successfully using the System.Json namespace to de-serialize data. Hence, for simplicity’s sake, I’d prefer to stick to that if possible. Unfortunately, I have no idea how to serialize with it (or if it is even possible).

  • System.Runtime.Serialization.Json.DataContractJsonSerializer
    The System.Runtime.Serialization.Json namespace is not available in MonoTouch. I’ve read somewhere that it is part of .NET 3.5 and that MonoTouch is at .NET 2.0 level. That might explain it.

  • System.Web.Script.Serialization.JavaScriptSerializer
    This one is also missing in MonoTouch (in fact, there only seems to be System.Web.Services available).

  • Json.NET by James Newton-King
    I managed to make this one work on the simulator by including the .NET 2.0 assembly dll and using Newtonsoft.Json.JsonConvert.SerializeObject(). However, this doesn’t compile for the device with error “mtouch failed with no output“. As soon as I remove the assembly reference, it compiles fine.

Is there any way to make one of those work with MonoTouch? Are there other alternatives to try?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:10:02+00:00Added an answer on May 20, 2026 at 5:10 am

    I’d recommend using the System.Json library, which is not too difficult to use and wrap in a class to make it strongly typed. It is also included as a default assembly with MonoTouch as it was inherited from Silverlight.

    To load it up:

    JsonValue value = JsonObject.Load(stream); //There are other overloads here, my stream is off an HttpWebRequest
    

    Here is an example by index:

    this.StringValue = value[0];
    this.IntValue = value[1];
    

    One my name:

    this.StringValue = value["StringValue"];
    this.IntValue = value["IntValue"];
    

    Where this is a class with a string property named StringValue and an int property named IntValue. For the most part, the JsonValue class will cast to your types implicitly.

    So what I do, is create a class to hold all of the Json info in a strongly typed way, then pass in a JsonValue in the constructor to do the ugly weakly typed stuff.

    For other libraries, you will run into problems where MonoTouch strips out types that are seen to be “unused” when created by reflection (as when you use XmlSerializer, for example). I have found myself fighting that issue more than necessary, having to add PreserveAttribute on types, etc.

    On this issue, read here for more info on Preserve: MonoTouch Doc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any clear documentation on the binary formats used to serialize the various
There are various ways to maintain user state using in web development. These are
There is a pretty strong need for us to design some workflows around various
So I was wondering if there are any major differences between the various implementations
I want to compare and contrast the various source control systems out there. Any
I've been evaluating various smart pointer implementations (wow, there are a LOT out there)
i've been making web app's and working with various server side language like php,
Looking ahead, to when a Web Farm will be created... We have various windows
in my application (c# 3.5) there are various processes accessing a single xml file
I've a DLL assembly, in which there are various classes. Each class has around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.