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

  • Home
  • SEARCH
  • 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 8322967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:33:50+00:00 2026-06-08T23:33:50+00:00

I hate to add to the 5,000+ JSON.NET deserialisation errors , but can anyone

  • 0

I hate to add to the 5,000+ JSON.NET deserialisation errors, but can anyone see anything that might be causing a problem in the following JSON below? Both JSONLint and JSONViewer state that the string is valid, indeed it has already been serialised by JSON.NET without any problem! The class definition for the Tariff object it represents is below too.

This has got me totally stumped – I have the exact same problem when I use .NET’s JavascriptSerialiser class too. It serialises fine, but on deserialisation it throws the following error:

Error converting value [JSON string below]
’emAPI.ClassLibrary.Tariff’. Path ”, line 1, position 374.

Line 1 pos 374 is between the 0 and the period in 0.5 at the end of the string, which represents double StandingChargeValue in the class.

Anyone any ideas on how to resolve?

Thanks, David

JSON String

{ "StandingChargePeriod": { "Id": 4, "Length": "Weekly", "NumbDays": 7 }, "Bands": [ { "Id": 24, "UpperkWhLimit": 23, "LowerkWhLimit": 0, "UnitRate": 2.4 }, { "Id": 25, "UpperkWhLimit": 0, "LowerkWhLimit": 24, "UnitRate": 5.8 }, { "Id": 26, "UpperkWhLimit": -1, "LowerkWhLimit": 0, "UnitRate": 5.8 } ], "Id": 10, "StartDate": "2012-12-07T00:00:00", "StandingChargeValue": 0.5 }

Tariff Class def

    public class Tariff
    {
        [ScaffoldColumn(false)]
        public int Id { get; set; }

        [Required]
        public DateTime StartDate { get; set; }

        [Required]
        [Range(0, 999999999)]
        public double StandingChargeValue { get; set; }

        public virtual Period StandingChargePeriod { get; set; }

        public virtual ICollection<TariffBand> Bands { get; set; }

}
  • 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-08T23:33:53+00:00Added an answer on June 8, 2026 at 11:33 pm

    OK so I finally worked it out after an all-night debug session…

    Like this problem about WCF serialisation, the problem revolved around trying to reserialise to an EF4.3 proxy object. To solve it, instead of returning the object from EF context directly:

    public getTariff(int id)
    {
        return context.Tariffs.Find(id);
    }
    

    I created a new object, copied over the attributes and returned the new object instead:

    public getTariff(int id)
    {
        Tariff holdingTariff = context.Tariffs.Find(id);
        Tariff tariff = new Tariff();
        tariff.X = holdingTariff.X;
        //repeat for all attributes
    
        return tariff;
    }
    

    Works like a charm. I’m not sure if this is designed behaviour or not, and it’s a bit of a pain as I need to repeat this pattern for a number of objects, but at least it works!

    Hopefully this will help someone else!

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

Sidebar

Related Questions

I see that some programmers add code that, after all, does not do anything
I hate generating an exception for things that I can simply test with an
I've learned (the hard way) that I need to add parentheses around JSON data,
I hate blocks. They are meant to make the code more concise, but I
I hate to post this but I am on a time crunch and need
I hate writing migrations, but it's important for the schemas to stay in sync.
I hate Wordpress for numerous reasons, but clients love it because it gives them
I hate to ask but I've searched all over the internet trying to figure
I hate to be the third person to ask this, but the previous two
I hate to be the village idiot, but I have no clue how Linq

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.