Converting string to jinja script - jinja2

I have a jinja script which I am sending from another service to a new service and it also has variables which when rendered should work as a normal jinja script. Eg :"scriptOne":"Hello Mr. {{userFirstname}}". When printed the text as{{scriptOne}} I need Hello Mr John wheras I am getting Hello Mr. {{userFirstname}}.
I tried only using the {{}}

Related

Display error message in HTML from Webseal

Hello I have an error page for user when their account gets locked. When I view the source code of page it just contains one line
%ERROR%
I am trying to understand if this is some kind of string interpolation as I have never seen it done with % sign. The error message that is displayed is this
The raw file you are viewing is a response page template. When that page is presented to the client making the request, the %MACRONAME% values are substituted and the HTML (or JSON) content returned from the web reverse proxy has that substituted text. Hint, you can further customize the messages to the user by substituting the macro into a javascript variable within the response page template, and then make logic decisions based on that client side javascript code. For example, you could catch one of the IBM error codes and translate it into saying something like "Account is locked".
More information is available on the macros within the IBM documentation.

Backslashes and other character combinations in logic apps json

I was wondering why logic apps connectors process json and then adds different characters like "\" "\r\n" and more, in json string when it goes through the workflow.
Is it possible to somehow dodge this problem in logic apps? how do i handle a problem like this best practice.
I have managed to create a Azure Function app that i use to remove these kind of characters and combination through a process of .Replace(). bu i feel like this could be done in a much better way.
Any ideas or suggestions would be much appreciated!
Example:
{
"Employee": "{\"Address\":\"507 - 20th Ave. E.\\r\\nApt. 2A\",\"BirthDate\":\"1948-12-08T00:00:00Z\",\"City\":\"Seattle\",\"Country\":\"USA\",\"EmployeeID\":\"1\",\"Extension\":\"5467\",\"Firstname\":\"Nancy\",\"HireDate\":\"1992-05-01T00:00:00Z\",\"HomePhone\":\"(206) 555-9857\",\"Lastname\":\"Davolio\",\"Notes\":\"Education includes a BA in psychology from Colorado State University in 1970. She also completed \\\"The Art of the Cold Call.\\\" Nancy is a member of Toastmasters International.\",\"PhotoPath\":\"http://accweb/emmployees/davolio.bmp\",\"PostalCode\":\"98122\",\"Region\":\"WA\",\"ReportsTo\":\"2\",\"Title\":\"Sales Representative\",\"TitleOfCourtesy\":\"Ms.\"}"
}
It depends on the expected type of the connector input. For example, HTTP Body or Azure DocumentDB expect type of "object". For those there are no escape characters added and JSON is serialized as-is. However some connectors have a field which is a string like Email Body. In that case the designer takes the input from designer and stringifies it (escaping characters) so a valid string is sent.
Which connector are you referencing here?

Using json_encode in a php web service

I have developed a web service with php, PDO and nusoap. I use json_encode() function to returns an array as a result of my web service functions. In the array there are persian characters and result is like:
\u062c\u0627\u0645 \u0645\u0644\u062a\u0647\u0627\u06cc \u0627\u0631\u0648\u067e\u0627
I also used JSON_UNESCAPED_UNICODE inside json_encode() and the result is:
جا٠ÙÙتÙØ§Û Ø§Ø±Ùپا
How can I solve my problem to show persian characters correctly?

How to properly encode ATG commerce JSON taglib droplet response

I had a problem where I was doing an jquery $get for a list of schools. I was using an RQLForeach droplet to retrieve the list and specified the output to be JSON, I would then take the returned JSON and use jQuery template to render out the result.
Problem I was seeing the following in the output King'swhich should've been King's School.
I used the {{html schoolName}} Which was supposed to take care of the decoding correctly. But it did not....
The solution to the problem.
Problem: Was that encoding and decoding was happening twice. First the json:object that gets output from the droplet was already escaping XML. So would therefore encode the & of the apostrophe. i.e. it was reaching client side as
&amp#39; instead of '. Therefore the {{hmtl}} could not decode it correctly
Answer: set the <json:object escapeXml="false"> this meant that by the time it reaches client side it was in the correct format ' to be decoded by the jquery {{html }} tag.

How to extract specific elements from the Google Geocoding json response through a URL?

So I want to be able to run this
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address
which returns a json response with many results...
Id like to be able to parse the json from the url itself...
so something like. ....
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&results[0].formatted_address
so that instead of getting a multiline response - I just get what I need in a single line such as...
277 Bedford Avenue, Brooklyn, NY 11211, USA
Sure I can write a script to do this but I wonder if specific fields of the JSON are restful.
Am i talking smack or is this possible ?
Thank You
Although RESTful web services may utilize JSON, the fields of JSON results themselves are not RESTful. Parsing values from the URL would probably require you to change how Google handles url processing on the server end. You'll have to get that information programmatically.