Web Connection
Error calling methods in JSONSerializer
Gravatar is a globally recognized avatar based on your email address. Error calling methods in JSONSerializer
  Chris Jewell
  All
  May 1, 2020 @ 09:11am

Hi Rick,

I'm new to JSON and I'm trying to get my head around serialize and deserialize but I've hit an issue.

My test code to reproduce this error is as follows :

&& The JSON below was pre-captured from my webpage for testing

lcParms = "data%5B0%5D%5Burn%5D=1000&data%5B0%5D%5Bcat%5D=Test123ID&data%5B0%5D%5Bdes%5D=TestProductDes&action=create"

do wwJsonSerializer

oJSON = CREATEOBJECT("wwJsonSerializer")

lcJSON = oJSON.DeserializeJson(lcParms)

But, on the last line I get this error :

Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

In my 'webapp_main.prg' I have added set procedure to wwDotnetBridge and wwJsonSerializer with Addi

I have .NET 4.8 installed.

And I have checked the following files are in the 'deploy' folder : 'newtonsoft.dll' 'wwdotnetbridge.dll' 'wwipstuff.dll'

I assume I'm missing something else here, but I'm not sure what, could you kindly point me in the right direction?

Regards, Chris

Gravatar is a globally recognized avatar based on your email address. re: Error calling methods in JSONSerializer
  Rick Strahl
  Chris Jewell
  May 1, 2020 @ 11:34am

Uh, that isn't... JSON?

The data is UrlEncoded() and if unencoded it still isn't JSON. It looks like some strang PHP data structures.

This seems to work:

DO wwutils && load libs

lcData = UrlDecode("data%5B0%5D%5Burn%5D=1000&data%5B0%5D%5Bcat%5D=Test123ID&data%5B0%5D%5Bdes%5D=TestProductDes&action=create")
? lcData
? GetUrlEncodedKey(lcData,"data[0][urn]")

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Error calling methods in JSONSerializer
  Chris Jewell
  Chris Jewell
  May 2, 2020 @ 02:32am

Sorry, my mistake, looking at the instructions for the third-party tool I'm using, it does say it can return Json but not by default.

Should have realized that!

Anyway, thank you for putting me straight 😃

© 1996-2024