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 9201759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:05:47+00:00 2026-06-17T23:05:47+00:00

I am using Json.NET to serialize an object to be sent to a compact

  • 0

I am using Json.NET to serialize an object to be sent to a compact framework 3.5 device (lucky me).

My class on the compact device is:

public class Specification
{
        public Guid Id { get; set; }
        public String Name { get; set; }
        public String Instructions { get; set; }
}

The Json being returned sent to the device is (notice the null for instructions):

string json = @"{""Name"":""Test"",""Instructions"":null,""Id"":""093a886b-8ed4-48f0-abac-013f917cfd6a""}"; 

…and the method being used to deserialize the json is…

var result = JsonConvert.DeserializeObject<Specification>(json);

On the server I’m using the following to create the Json:

var serializer = new JsonSerializer();
serializer.Formatting = Formatting.None;
serializer.Serialize(context.HttpContext.Response.Output, this.Data);

The problem is that on the compact framework, it’s failing to put a value into result.Instructions which is causing a null reference when it is referenced later in the code.

I’m using Newtonsoft.Json.Compact v3.5.0.0 (I think that’s the latest version), and on the server I’m using Newtonsoft.Json 4.5.0.0.

Question

How can I either:

a) Change the server code to stick a “” instead of a null value in where a string is null.

or

b) Change the compact framework code to be able to handle null value strings.

Things I’ve tried

I’ve been looking through the documentation/examples of Json.Net and have tried a multitude of things like a implementing a DefaultContractResolver, and a custom JsonContract. Maybe the answer lies within those but my lack of understanding of Json.Net at this level isn’t helping!!

Further info

I was using System.Runtime.Serialization.Json.DataContractJsonSerializer for the server side serialisation, which did generated quotes in the event of empty strings. Unfortunately, I need more flexibility with the serialization which is why I’ve started using Json.Net.

Any hints/tips appreciated.

  • 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-06-17T23:05:48+00:00Added an answer on June 17, 2026 at 11:05 pm

    OK – no answers, but having search all yesterday afternoon I went to bed, and search again this morning to find: Serializing null in JSON.NET, which pretty much answers my question.

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

Sidebar

Related Questions

I am using Json.NET to serialize an object graph. For each object that is
I have an extension method for System.Object to serialize and deserialize objects using Json.Net
How do I serialize entity framework object into JavaScript Object (JSON)? I tried using
I am using Newtonsoft.Json .Net for 4.0 for this project Parent class: public class
Using the Newtonsoft.Json library, imagine I have got public class Test { public Object
I am trying to serialize a C# object to JSON using JSON.net library. The
I am using NewtonSoft.Json.JsonConvert.SerializeObject() to serialize an ASP.NET Dictionary object into a JSON string.
I have some data that I have to serialize to JSON. I'm using JSON.NET.
In ASP.NET MVC, I'm using JSON and jquery to get data for a chart.
I'm trying to create two method to serialize/deserialize classes using Json.Net and save/load them

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.