web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

I have problem with deserialize JSON

(0) ShareShare
ReportReport
Posted on by 30

Hi,

I am doing deserialize JSON Data.

        System.Net.WebClient web = new System.Net.WebClient();
        System.Net.WebHeaderCollection headers = web.Headers;
        headers.Add("Content-Type","application/json");

        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
        str json = FormJsonSerializer::serializeClass(request);
        System.Byte[] encodedBytes = encoder.GetBytes(json);
        System.Byte[] response = web.UploadData(_sbURI "/sb-api/request/",encodedBytes);
        str jsonResponse = web.Encoding.GetString(response);

        //I have Problem in Here!!
        values = FormJsonSerializer::deserializeCollection(classNum(List),jsonResponse,Types::String);
        value = values.getEnumerator();
        while(value.moveNext())
        {
            Box::info(value.toString());
        }

Here is my Code.

I POST JSON Data to API, and I got Data(JSON) successfully.

{"MessageId":"Ajinsoll-y8k5m4q2-k8k6","Signal":"ARISSUE_FINISH","ConversationId":["38581018361238112345202005300019006","ResponseTime":"20200530115119","ResultCode":"37002","ResultMessage":"Good","ResultDataSet":{}}

I want to deserialize this data form. But I can't do this...

I give ResultModel Class too.

[DataContract]
class SYC_TestX_ResultModel
{
    str MessageId;
    str Signal;
    List ConversationId;
    str ResponseTime;
    List ResultCode;
    str ResultMessage;

    [DataMemberAttribute('MessageId')]
    public str MessageId(str _MessageId = MessageId)
    {
        MessageId = _MessageId;
        return MessageId;
    }

    [DataMemberAttribute('Signal')]
    public str Signal(str _Signal = Signal)
    {
        Signal = _Signal;
        return Signal;
    }

    [DataMemberAttribute('ConversationId')]
    public List ConversationId(List _ConversationId = ConversationId)
    {
        ConversationId = _ConversationId;
        return ConversationId;
    }

    [DataMemberAttribute('ResponseTime')]
    public str ResponseTime(str _ResponseTime = ResponseTime)
    {
        ResponseTime = _ResponseTime;
        return ResponseTime;
    }

    [DataMemberAttribute('ResultCode')]
    public List ResultCode(List _ResultCode = ResultCode)
    {
        ResultCode = _ResultCode;
        return ResultCode;
    }

    [DataMemberAttribute('ResultMessage')]
    public str ResultMessage(str _ResultMessage = ResultMessage)
    {
        ResultMessage = _ResultMessage;
        return ResultMessage;
    }



}

Can You help me???

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi SYNCS,

    You are trying to deserialize JSON with one record and multiple fields to a multi-record string object. In your case, you can deserialize JSON directly to contract with deserializeObject option.

    SYC_TestX_ResultModel contract = FormJsonSerializer::deserializeObject(classStr(SYC_TestX_ResultModel), jsonResponse);

  • SYCNS Profile Picture
    30 on at

    SYC_TestX_ResultModel result = FormJsonSerializer::deserializeObject(classNum(SYC_TestX_ResultModel),jsonResponse);

    I'm trying this Code, it works Good. Also, I modified the ConversationType to Str. Thank you for reply!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans