I have data which is serialized as JSON which then has to be added to the Dynamics PluginExeutionContext in a SharedVariable. The Problem is that the JSON content is passed as string and cannot be parsed as JSON on the other side of the receiver.
This is how it is passed now:
"SharedVariables": [
"key": "Telemetry_Log",
"value": "JsonContent"
},
]
What I need is to have the "JsonContent" without double quotes like this
"SharedVariables": [
"key": "Telemetry_Log",
"value": JsonContent
},
]
First I have serialized the data into JSON and passed the string to the context like so:
_executionContext.SharedVariables.Add(TelemetryLogSharedVariables.CustomUserLog.GetDescription(), _loggerContainerUser.ConvertToJson()
second try was to return a list of CRM Entities hoping that Dynamics will serialize it.
the last try was to cast the JSON string to an object:
_executionContext.SharedVariables.Add(TelemetryLogSharedVariables.CustomUserLog.GetDescription(), (Object)_loggerContainerUser.ConvertToJson()
Nothing worked and I always got the JSON string in double quotes.
Does anybody have an advice?
You have to “Create a DataContract class that will define datamodel for JSON data” and deserialize (reverse engineer) the JSON string into Object using
DataContractJsonSerializer
on the other end. Read moreOrigin: Serialize Data in JSON string
Destination: Deserialize Data obtained in JSON string to an object