Question
Union Bank
US
Last activity: 24 Jun 2020 22:44 EDT
Openspan 7.1.x studio issue - How to use the installed OpenSpan.JSON.js file for parsing JSON?
Hello Pega gurus,
There is a file, OpenSpan.JSON.js, that came with Openspan Studio 7.1.x install that is internally documented to provide for parsing of JSON. And I quote "...This file creates a global JSON object containing two methods: stringify and parse...".
It is installed at this location: C:\Program Files (x86)\OpenSpan\OpenSpan Studio for Microsoft Visual Studio 2010\Application\JavaScript\Universal\
Advise us how I am to integrate this provided "OpenSpan.JSON.js" into my project, and how do I call it to perform needed parsing? This is vital to a large time critical project that we are working on.
Thanks,
Tom Overton
***Edited by Moderator: Pallavi to update platform capability tags***
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
Given that folder location it is likely for internal use only. It is not a component that you can add to your toolbox. If you'd like to parse JSON, there is a component available in later versions named JSONUtils. You'd need to update your code to a later version though as this was not available in 7.1. I would suggest getting the latest 19.1 build and using that if you plan to upgrade, although you may need to do some work (upgrade to each intermitent version first) going from such an old version. I mainly expect scripts to be your issue upgrading, but those should be rather easy to resolve. I would expect everything else to work though.
Union Bank
US
Hello Thomas,
Thank you for your answer. Unfortunately I can't upgrade at this time from Openspan 7.x to Openspan 8SP1. Are the needed JSON libraries found in Openspan 8SP1 such as JSONUtils?
What did y'all do in Openspan 7.x when you had to deal with JSON back then? I have written a script to call the REST API in question and retrieve back the JSON. But my problem is parsing the JSON reply.
Thanks, Tom
Pegasystems Inc.
US
What are you trying to do? I saw another post you had about using the Newtonsoft dll for something. We used to use that to serialize objects to strings to pass them back and forth. I don't really recall needing to parse any JSON in the 7.1 days.
Union Bank
US
Hello Thomas,
I must change my code to now call several new APIs submitting a variable to them when I call them. I created a script that called the API, and gathered back the string that is the JSON reply from the API. My problem lies that I then need to parse that JSON reply to get the value from each "Items:value" pair in the Json String.
For example, if the JSON has a item:string value in the pair {...,"color":"red",...} I need to get "red" and place it to a string variable strColor. If the JSON reply has an int value in the pair {..."mph":142,...} I need to get 142 and pass it to an int variable intMPH. So, as you can see I need to parse that JSON reply string to access each item:pair value. Or I need to parse the whole string into an array and access it thusly.
Also, does Openspan 8SP1 contain the JSONUtils you mentioned?
Pegasystems Inc.
US
8.0 SP1 does include the JSONUtils component.
Union Bank
US
Thank you Thomas,
I hope in the future I can move to 8 SP1. In the meantime I must make Openspan 7.1.59 meet our immediate code change requirements.
As you know I have been directed to change my code to call APIs and parse the JSON response. I have been directed here to do without upgrading to Openspan 8SP1, on this project. The problem has been that Openspan Studio 7.1.59 scripts do not recognize the needed items that I add as project references.
Openspan Studio 7.1.59 allows meto add Newtosoft.Json to the Openspan project, but then in the script when I say “using Newtosoft.Json;” it says “script is invalid. The type or namespace name ‘Newtonsoft’ could not be found…”. No variation on syntax allows Newtosoft.Json to be recognized and used.
How do I add the needed references in a way to force scripts to see them? What file do I need to edit so Openspan 7.1.59 scripts can use the referencs in the project.
Help please,
Tom
Pegasystems Inc.
US
I believe the issue is something with your specific reference. Are you sure that Newtonsoft.JSON is the correct namespace to add to the using section? I don't have a machine where I can install that old of a version on to try myself, so your only option is to try opening a support request. I suspect though that the version you are using will be too old for them to be able to do much, but perhaps they can get on with you on your machine to take a look.
Pegasystems Inc.
US
Unfortunately, I do not have a machine that would run 7.1.59 to try to assist from my end. You might try opening a support request to see if they can get on with you to assist, but this may be out of their realm of experience or perhaps that version may be too old for support. Without getting hands-on with that version, I'm not sure there's much I can suggest. You don't need Newtonsoft though to parse JSON. There are other ways to do so in .Net that you could use. Here's an example I found that might be helpful.
https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c