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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:05:19+00:00 2026-06-09T18:05:19+00:00

Pretty simple thing to do and I can’t figure this one out for some

  • 0

Pretty simple thing to do and I can’t figure this one out for some reason. I have a mock JSON file that looks like so:

  {
  "AccountId":"XXXXXXXXX",
  "UAN":"PE3458234758345",
  "BillingName":"John Smith",
  "BillingAddress": {
    "Address1":"701 First Ave.",
    "Address2":"test",
    "City":"Philadelphia",
    "State":"PA",
    "Zip:":"19147"
  },
  "ServiceStartDate":"5/1/2012",
  "PromoCode":"0056",
  "PartnerCode":"AAL",
  "MemberNumber":"0000001",
  "Invoices":[
    {
      "Amount":"113.78",
      "Date":"6/1/2012",
      "Usage":"3143"
    },
    {
      "Amount":"123.56",
      "Date":"7/1/2012",
      "Usage":"4561"
    },
    {
      "Amount":"105.23",
      "Date":"8/1/2012",
      "Usage":"5454"
    }
  ],
  "Expected":[
    {
      "AwardCreation":"true",
      "AwardAmount":"500",
      "AwardUnits":"usd",
      "AwardDate":"today()"
    }
  ]
}

And I’m needing to create a dynamic object from this as this can vary each time a test mockup is ran. I’ve tried the custom deserializer as noted in this solutio as well as the .NET 4.0 System.Web.Helpers and in both cases I end up with:

Invalid JSON primitive: \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0...

Currently my working test is:

var json = new StringBuilder();

        using (var fs = File.Open(@"c:\users\bryan\Desktop\test2.json", FileMode.Open))
        {
            var byteArray = new byte[1024];
            var tempString = new UTF8Encoding(true);

            while (fs.Read(byteArray, 0, byteArray.Length) > 0)
            {
                json.Append(tempString.GetString(byteArray));
            }
        }

       var dynamicObject = Json.Decode(json.ToString());

       Assert.IsNotNull(dynamicObject);

I have no clue, I guess it’s the format? I’ve stripped everything out of the json file (meaning one giant line) and I get the same thing. Oddly, when I use Newtonsoft.Json I don’t get the error, but the dynamic object is just the AccountId string and nothing else.

  • 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-09T18:05:20+00:00Added an answer on June 9, 2026 at 6:05 pm

    You code to read UTF-8 file is wrong as it:

    • tries to convert potentially incomplete byte sequences due to cutting of on 1024 bytes boundary
    • appends extra 0 bytes due to ignoring length of the file in last segment.

    Consider using StreamReader or some other built in method to read string from file. See How to:Read Text from a File and File.ReadAllText for starting points.

    var dynamicObject = Json.Decode(
      File.ReadAllText(@"c:\users\bryan\Desktop\test2.json"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
What I want is pretty simple conceptually but I can't figure out how it
This is probably pretty simple, but here: Say I've got two models, Thing and
This should be a pretty simple thing to do with Update Panels, but I'm
This should be a pretty simple thing to do. The user puts his finger
I have a pretty simple thing I'm doing with javascript and basically only sometimes
I think this is a pretty simple question. How do you an apache rewrite
I think I have a pretty simple goal but cant seem to reach it.
Pretty simple question. I'm quite certain I have the Class, method, codebehind, etc linked
Pretty simple question. I've got some Polygons and GroundOverlays defined in KML. Is there

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.