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

Notifications

Announcements

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 135
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
    238,286 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,158 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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans