Web Connection
DeserializeJson question
Gravatar is a globally recognized avatar based on your email address. DeserializeJson question
  Michele
  All
  May 25, 2018 @ 08:42am

Why when i pass to this function a string like this

{ "id": 50445, "message": "", "session": "_57J11K9FN", "status": 0 }

i receive an object where i have no id property but only the other three ? Is "id" a reserved key ?

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Rick Strahl
  Michele
  May 25, 2018 @ 10:29am

Not sure but that works for me:

DO wwjsonserializer

lcJson = '{ "id": 50445, "message": "", "session": "_57J11K9FN", "status": 0 }'

loSer = CREATEOBJECT("wwJsonSerializer")
loResult = loSer.DeserializeJson(lcJson)

*** 50445
? loResult.Id

There should be no reserved words for deserialized objects other than illegal FoxPro property names (ie. starts with a number, any sign characters other than _ etc.).

Is it possible you have an old or mismatched copy of wwDotnetBridge? This might explain your other issue as well.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Michele
  Rick Strahl
  May 28, 2018 @ 07:35am

Reinstalled Web Connection. It seems to work...

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Rick Strahl
  Michele
  May 28, 2018 @ 01:16pm

Does that fix both of the problems?

Just FYI - I don't change wwDotnetBridge and the support pieces often but they do change from time to time, so always make sure you're using a matched set of PRG -> DLLs. If the DLL interfaces change weird stuff can happen as you apparently found out.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Michele
  Rick Strahl
  May 29, 2018 @ 01:35am

It solved only this problem.... The serialization problem explained in other message is not still solved.... I'm still trying to understand why i have it... If you remember i received null values if i pass to Serialize function an object like ThisForm.oObject I create a sublevel methods in my class form where i make this operation

Lparameters lvValue

Do Case
	Case Type("lvValue") = "O"
		lvSerial = CreateObject("Empty")
		lnConta = AMembers(aProps,lvValue)
		For ii=1 To lnConta
			lcField = "lvValue." + aProps[ii]
			AddProperty(lvSerial,aProps[ii],&lcField)
		EndFor
	Otherwise
		lvSerial = lvValue		
EndCase
lcJson = This.oSer.Serialize(lvSerial)

Return lcJson

Where i receive the original object and i transform it into another one and it works.... why i don't know.... for the moment i use it in this way.....

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Rick Strahl
  Michele
  May 29, 2018 @ 11:51am

Hmmm... that doesn't make any sense to me. An object is an object, unless there's a scope issue. Could it be that the properties on this object are protected or private so that they are not visible once they enter the context of the Serializer object?

Did Thierry's advice help setting a breakpoint and looking at the call stack? That should show you exactly where the values are getting lost as you can examine the state up the call stack.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: DeserializeJson question
  Michele
  Rick Strahl
  May 29, 2018 @ 03:01pm

Tomorrow morning, i'll apply Thierry's suggest

© 1996-2024