Web Connection
newtonsoft.json.dll
Gravatar is a globally recognized avatar based on your email address. newtonsoft.json.dll
  Stein Goering
  All
  Nov 1, 2016 @ 11:39am

Has anyone else run into issues when applying the newtonsoft dll to format json output?

It works fine on my development system, but I've had numerous customers report errors from their production sites.

"OLE IDispatch exception code 0 from Newtonsoft.Json: Error reading JToken from JsonReader.
I've told them to make sure the DLL was not blocked and they assured me it wasn't. So I added a config setting that forces the oJSONSerializer.formattedOutput property to False, which appears to avoid the Newtonsoft call.

Is there any reason I can't just make that the default? As far as I can see, the effect is primarily cosmetic and no actual functionality is affected by turning formattedOutput off.

--stein

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Rick Strahl
  Stein Goering
  Nov 1, 2016 @ 04:36pm

Hi Stein,

Well I think the underlying problem is that hte JSON generated may be invalid. The formatter is a good way to check for validity of the JSON.

It would be good to know what JSON is when the error occurs.

Turning off the formatting is not a problem. It should really only be on in debug mode anyway. Just checking the code for wwJsonSerializer, the property is false by default and in the wwJsonService it's only in DebugMode. So unless you've changed the setting yourself or you're running in Debug mode, this shouldn't generating formatted output in the first place.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Stein Goering
  Stein Goering
  Nov 1, 2016 @ 10:11pm

What's being formatted is this output:

  lcOutput = loJSON.Serialize("cursor_legacy:"+lcCursor)
Does using the cursor_legacy flag result in invalid JSON? Except if that's the case, it should have failed on my development system but I've never had a problem here.

In any case, I'm going to go back to your defaults so it only invokes formatting in Debug Mode. Not sure where I got the idea that it should always be active.

--stein

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Rick Strahl
  Stein Goering
  Nov 2, 2016 @ 02:12am

It shouldn't be but I can't account for another reason why the format would fail. Maybe there's an invalid name? Not sure best thing to do is see if you can capture the JSON.

Note that all of this does require, .NET 4.0 or later. It's possible that perhaps the 2.0 version is getting loaded instead and maybe that's the problem?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Stein Goering
  Rick Strahl
  Nov 5, 2016 @ 10:51pm

The .NET version issue might be a factor - some of our customers tend to leave legacy settings in place - could easily still be running under .NET 2.0. That might explain why we saw errors on some sites while it worked fine on others. But I've now got it back to your defaults so it should not come up at all unless they invoke Debug Mode.

--stein

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Rob Corbett
  Stein Goering
  May 29, 2017 @ 08:54am

I ran into this issue also. After checking the passed JSON, it was occasionally empty. I added a check to ensure proper/non-empty JSON before the call. But, I also noticed that newtonsoft.json.dll File Description is "JSON.NET .NET 2.0", File Version: 6.0.3.17227. On the Newtonsoft website they are up to 10.0.2. Why is the description for .NET 2.0? Any chance of updating WC to the latest version?

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Rick Strahl
  Rob Corbett
  May 30, 2017 @ 12:28am

The features we actually use in the Newtonsoft.Json library is very small and the 6.0 version is smaller and works with .NET 2.0 for those that are running with the 2.0 runtime.

You can easily use a newer version if you wish, but it'll require using assembly redirects.

More info in this blog post, which outlines some of the issues:

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: newtonsoft.json.dll
  Rob Corbett
  Rick Strahl
  May 30, 2017 @ 09:54am

Ok, thanks for the info Rick.

© 1996-2017