Is there a way in spark ar to convert scalars to string through the patch editor and not scripting? - spark-ar-studio

I'm trying to set a scalar value that I get from script into a string through the patch editor to put it into a 2Dtext object. I can't do it via script because I need it to look like its counting up. does anyone know how to convert a scalarvalue to an int by only using the patch editor?image of what I'm doing / have tried.2

Related

Reading the Json string which is put together in one field

I have a Json pattern string in a text file, I have to pharse the below string like below and put it in to a external file.
Please let me know how this can be handled with Informatica Powercenter or Unix or Python?
{"CONTACTID":"3b2a25b2","ANI":"+16146748702","DNIS":"+18006081123","START_TIME":"01/22/2023 03:31:42","MODULE":[{"Name":"MainIVR","Time":"01/22/2023 03:31:42",Dialog":[{"name":"offer_Spanish","dialogeresult":"(|raw:7|R|7|1.0|nm=0|ni=0|2023/22/21 03:02:01)"}],"backend":[{"Time":"01/22/2023)"}],"END_STATE":"XC"}
In The above sample string the special charcters should be removed and the values should be assigned to the corresponding columns like below 2 o/p formats
Output:
CONTACTID, ANI, DNIS, START_TIME, MODULE, Time,Dialog,dialogeresult,END_STATE
3b2a25b2,+16146748702 +18006081123 01/22/2023 03:31:42,Name:MainIVR,
or
Output:
CONTACTID : 3b2a25b2
ANI:16146748702
DNI :+18006081123
I tried this to read thru Informatica powercenter and using the expression tranformations but nothing worked and tried with Python too.
For a start, your JSON is invalid. The opening double quotes for Dialog are missing and it's not properly closed - MODULE array is not closed and root is not closed. Here's the fixed JSON:
{"CONTACTID":"3b2a25b2","ANI":"+16146748702","DNIS":"+18006081123","START_TIME":"01/22/2023 03:31:42","MODULE":[{"Name":"MainIVR","Time":"01/22/2023 03:31:42","Dialog":[{"name":"offer_Spanish","dialogeresult":"(|raw:7|R|7|1.0|nm=0|ni=0|2023/22/21 03:02:01)"}],"backend":[{"Time":"01/22/2023)"}],"END_STATE":"XC"}]}
Use some JSON validation tool, like this one - it helps a lot.
Next, here's some starter code you may use to achieve the required result:
import json
# some JSON:
x = '{"CONTACTID":"3b2a25b2","ANI":"+16146748702","DNIS":"+18006081123","START_TIME":"01/22/2023 03:31:42","MODULE":[{"Name":"MainIVR","Time":"01/22/2023 03:31:42","Dialog":[{"name":"offer_Spanish","dialogeresult":"(|raw:7|R|7|1.0|nm=0|ni=0|2023/22/21 03:02:01)"}],"backend":[{"Time":"01/22/2023)"}],"END_STATE":"XC"}]}'
# parse x:
y = json.loads(x)
# the result is a Python dictionary:
print(y.keys())
You may test it on Replit
Finally regarding Informatica Powercenter - it is a terrible choice for complex string processing. You would need a Hierarchy Parser Transformation. Long story short: it's very tedious, but possible. I would highly recommend picking up a differen approach, if this is not a regular data loading process you will need to build.

How to write a dictionary value when calling a function in Power Query/M Language?

I have a function that queries data from an external api (making a power connector). I need one of my inputs for the api to be json text (could be nested json). However from the Power BI UI side, I can only pass in things like numbers, text, lists... I could write it as a JSON encoded string like this
MyLibrary.GetData("{""key"":{""key2"":""value""}}")
But this looks messy. I would like to write it natively like this for example (then convert it to json text in M language).
MyLibrary.GetData({"key":{"key2":"value"}})
How can I do this?
Figured it out. There is a record type like this [key=Value]. Value can be any type.

How to parse lua table object into json?

I was wondering if there was a way to parse a lua table into an javascript object, without using any libraries i.e require("json") haven't seen one yet, but if someone knows how please answer
If you want to know how to parse Lua tables to JSON strings take a look into the source code of any of the many JSON libraries available for Lua.
http://lua-users.org/wiki/JsonModules
For example:
https://github.com/rxi/json.lua/blob/master/json.lua
or
https://github.com/LuaDist/dkjson/blob/master/dkjson.lua
If you do not want to use any library and want to do it with pure Lua code the most convenient way for me is to use table.concat function:
local result
for key, value in ipairs(tableWithData) do
-- prepare json key-value pairs and save them in separate table
table.insert(result, string.format("\"%s\":%s", key, value))
end
-- get simple json string
result = "{" .. table.concat(result, ",") .. "}"
If your table has nested tables you can do this recursively.
The are a lot of pure-Lua JSON libraries.
Even me have one.
How to include pure-Lua module into your script without using require():
Download the Lua JSON module (for example, go to my json.lua, right-click on Raw and select Save Link as in context menu)
Delete the last line return json from this file
Insert the whole file at the beginning of your script
Now you can use local json_as_string = json.encode(your_Lua_table) in your script.

Unable to get data from JSON in Applescript

So I'm able to get the values from one api but I'm unable to get the second value, which is a currency conversion rate (from an entirely different source). I've pasted my code below, any help would be much appreciated.
set json to (do shell script "curl https://www.bitstamp.net/api/v2/ticker/xrpusd")
tell application "JSON Helper"
set result to read JSON from json
set price to |last| of result as number
end tell
set json to (do shell script "curl https://api.fixer.io/latest?symbols=INR")
tell application "JSON Helper"
set result to read JSON from json
set inr to |INR| of result as number
end tell
set result_string to "₹" & price * inr & ""
If I open the second URL in a browser, here’s the JSON that gets returned (formatted for easier reading):
{"base":"EUR",
"date":"2018-02-05",
"rates":{
"INR":79.744
}
}
The INR value is inside the rates value. Therefore, you need to reference it like so:
set inr to (INR of rates of result) as number
I don’t see any reason to enclose INR inside vertical bars, as there’s no conflicting AppleScript commands or variables with that name. You can even get away with defining inr as a user-defined variable, and AppleScript will be able to distinguish when you’re referencing that from when your referencing INR of rates.
However, result is a pre-defined AppleScript property, so I would avoid using this in the way that you have. What you can do is change this line:
set result to read JSON from json
to this:
read JSON from json
and keep the subsequent line as it is (with my suggested correction from above). Now you’ll be using the AppleScript result property correctly.

Parse JSON in to Strings with escape characters for GWT Test Case

I've come up with a doubt around JSON files.
So, we're building a test case for a GWT application. The data it feeds from is in JSON files generated from a SQL database.
When testing the methods that work with data, we do it from sources held in String files, so to keep integrity with the original data, we just clone the original JSON values in to a String with escape sequences.
The result of this being that if a JSON entry shows like this:
{"country":"India","study_no":87}
The parsed result will come up like this in order for our tools to recognise them:
"[" + "{\"country\":\"India\",\"study_no\":87}" + "]"
The way we do it now is taking each JSON object and putting it between "" in IntelliJ, which automatically parses all double quotes in to escape sequences. This is ok if we only wanted a few objects, but What if we wanted a whole dataset?
So my question is, does anyone know or has created an opensource script to automate this tedious task?
One thing you could do is to wrap window.escape() using JsInterop or JSNI. For example:
#JsType(isNative="true", name="window")
public class window {
public native String escape(String toBeEscape);
}
and then apply to your results.