Announcements
Hi All,
I have a problem when deserializing the JSON String thrown by the D365FO using the JSON Service. I tried setting the header to Accept application/json.
The class attached to the service:
[AifCollectionType('return', Types::RString, extendedTypeStr(Name))]
public anytype processData(ContractOfJsonReceived jReceived)
.
// Process Data
.
ContractOfJsonReturn jReturn;
str JSonStr = FormJsonSerializer::serializeClass(jReturn);
Then please mark reply (or replies) that answer the question. This will make clear that the thread doesn't need more answers and anybody finding the thread can easily find the solution.
Hi Martin,
This is close my query on this thread. Thank you very much it is now working
Hi Martin,
Will check on this. Anyways I'm a huge fan of yours, I've learned a lot from your articles around here. Thank you very much
A service operation returns data, which is then returned by the web service in JSON. Typically the data is a contract object and the web service returns this object serialized to JSON. But not in your case - instead of returning an object, you explicitly serialize it to a string and you return this string, therefore you get this string wrapped in JSON.
The solution is throwing away your code with FormJsonSerializer and returning jReturn object directly. You'll also have to change the return type to ContractOfJsonReturn. And throw away AifCollectionType, because you're not returning a collection (such as a list of contract objects).
Hi Martin,
Sorry I wasn't able to describe more about my problem. The problem I encounter is that the response I received was enclosed with double quotes and the postman interprets it as a string. I'm hoping I can receive it as a JSON Object.
Example:
"{\"Number Sequence\":123,\"Reference Number\":\"IHL | RMF-RAFI-PAY-RFP-000000236\"}"
What I want to achieve is having a result of
{
You said you had a problem, but it's not clear to me what kind of problem.
If you want to serialize the string to objects but you refuse to use the library doing exactly that, then what do you really want?
By that way, the application I'm using to simulate pushing of data is Postman. And I do understand that people here would push me to develop this using NewtonSoft.JSON.Net on C# yet I want to know the workaround for this. Thank you
André Arnaud de Cal...
294,157
Super User 2025 Season 1
Martin Dráb
232,938
Most Valuable Professional
nmaenpaa
101,158
Moderator