The classToJSON() calls is taking a string like this: http://localhost:15004/productCatalogManagement/productSpecification/000000074adda99d0000242800000b6871de9069
And producing the following: “href”:”http:\/\/localhost:15004\/productCatalogManagement\/productSpecification\/000000074adda99d0000242800000b6871de9069″
The escaped string is what is returned in the REST response JSON, which is not desirable.
How can this be fixed?
you must escape each forward slash with two backward slashes. So the string must be:
The answer from me was wrong.
The jsonToClass() operation handles input strings with / as expected:
href: Base Types.String = “http://serverLocation:port/partyManagement/organization/Google”
role: Base Types.String = “Developer”
href: Base Types.String = “http://serverLocation:port/partyManagement/organization/LG”
role: Base Types.String = “Manufacturer”
I’d expect to not have to escape the / on the classToJSON() call to be consistent with the jsonToClass() operation. No?
You are right that the classToJSON() and jsonToClass() must be consistent. My first answer was wrong too.
It is a bug in classToJSON() that the slash is escaped with a backslash.
I created issue RUN-1839 for this.
As a workaround you must post process the classToJSON() output.
When do you need a fix?
Thanks for looking at this further and opening a bug report.
I have a workaround but it needs to go into around 200 ActionScripts for REST operations in 16 TMF REST APIs I’ve built – Party, Customer, Product Catalog, Service Catalog, Resource Catalog, Product Order, Service Order, Resource Order, Product Inventory, Service Inventory, Resource Inventory, Usage, Billing, SLA, Performance, Ticket
So sooner rather than later for the bug fix would be very good.
This is the workaround:
local outputString = createdProductSpecification.classToJSON();
set outputString = outputString.replace(“\Q\/\E”, “/”);
set outputContent = transcodeToBlob(outputString, “utf-8”);
The issue RUN-1839 is now fixed with Runtime 2015.1.