bildwelt
E2E FORUM
E2E Bridge E2E Commerce

String forward slashes being escaped in classToJSON()

E2E Forum Modeling & Development String forward slashes being escaped in classToJSON()

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Alfred 2 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1796

    Cliff Faurer
    Participant

    Hello,

    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?

    Thanks,
    Cliff

    #1797

    Alfred
    Moderator

    Hi Cliff,

    you must escape each forward slash with two backward slashes.

    So the string must be:
    http:\\/\\/localhost:15004\\/productCatalogManagement\\/productSpecification\\/000000074adda99d0000242800000b6871de9069

    The answer from me was wrong.

    Alfred

    #1799

    Cliff Faurer
    Participant

    Hi Alfred,

    The jsonToClass() operation handles input strings with / as expected:

    “relatedParty”:
    [
    {
    “href”: “http://serverLocation:port/partyManagement/organization/Google”,
    “role”: “Developer”
    },
    {
    “href”: “http://serverLocation:port/partyManagement/organization/LG”,
    “role”: “Manufacturer”
    }
    ]

    becomes:

    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?

    Thanks,
    Cliff

    #1800

    Alfred
    Moderator

    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?

    #1801

    Cliff Faurer
    Participant

    Hi Alfred,

    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”);

    Thanks,
    Cliff

    #1803

    Alfred
    Moderator

    The issue RUN-1839 is now fixed with Runtime 2015.1.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.