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

Community site session details

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

Remove invalid character \" from API JSON

(0) ShareShare
ReportReport
Posted on by 133
Hello experts,

I have created custom API and I am expecting following JSON format but I have received different format :
Looking your help to get the expected JSON (Extra  character added in JSON, how to remove  from the JSON to match the expected JSON)

Actual JSON format: Extra invalid character added in JSON



Expected JSON format:
 
Code:
 
        salesOrderList                            =  _request.ParmSalesOrder();
        ListEnumerator  ListLineEnumerator       =  salesOrderList.getEnumerator();
        while(ListLineEnumerator.moveNext())

      {
           salesOrderListContract = ListLineEnumerator.current();
            
            salesOrderLineResonse = new XXX_SalesOrderLineResonse();
            salesOrderLineResonse.parmOrderNum(salesOrderListContract.ParmSalesOrderList());
            orderList.addEnd(salesOrderLineResonse);
        }
        salesOrderResponse = new XXX_salesOrderResponse();
        salesOrderResponse.parmLine(orderList);
        
        str jsonSerializedContractResponse = FormJsonSerializer::serializeClass(salesOrderResponse); // convert the object to JSON response
   
       
        jsonSerializedContractResponse = strReplace(jsonSerializedContractResponse,/////, //);   //To remove backward slash and / from the output
       
        return jsonSerializedContractResponse;
 
Output: 
I have the same question (0)
  • Verified answer
    Layan Jwei Profile Picture
    8,034 Super User 2025 Season 2 on at
    Remove invalid character \" from API JSON
    Hi KomalG,
     
    When you say custom API, do you mean custom service?
     
    If yes, then as Martain said, are you looking at debugger? Cause the result might be correct. Try to call the custom service vis postman for example and check if the result returned is correct or not (without the need to remove "\"
     
    Thanks,
    Layan Jweihan
  • Verified answer
    Martin Dráb Profile Picture
    236,258 Most Valuable Professional on at
    Remove invalid character \" from API JSON
    How are you checking the result? If you're looking at a variable in debugger, the whole problem may be in how the data is shown there. Try saving it to a file, for example.
     
    By the way, why are you trying to serialize the contract object by yourself? You should return the contract object from your custom service; F&O will do the serialization for you.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,257

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 611 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans