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

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
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at
    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.
  • Verified answer
    Layan Jwei Profile Picture
    8,114 Super User 2025 Season 2 on at
    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

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
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans