JSON-OBJECT/From-FILE  [SOLVED]

Discuss your general Proclaim related queries here.
Code Killer
Posts: 45
Joined: Thu Oct 29, 2015 10:04 am
Location: Kent
Has thanked: 33 times
Been thanked: 3 times

JSON-OBJECT/From-FILE

Post by Code Killer »

Hi All,

I've just noticed these new functions on the 'INDEX: list of Proclaim Maths functions' page:

JSON-ARRAY-FIRST/GET-COUNT/INDEX/LAST/NEXT/PREV
JSON-GET-NAMES/PROPERTY/PROPERTY-TYPE
JSON-OBJECT/From-FILE

I've played around a bit with JSON, does anyone have any idea how this works with Proclaim? :?:

I'm assuming by the naming it takes a .JSON file from a file directory? :geek:

I've seen the post below which refers to externally taking JSON and using a JavaScript library to parse it into XML so it could be imported, but these functions suggest that there are possibly now means to manipulate JSON internally. :idea:

viewtopic.php?t=264

Thanks again!

John :D

danny
Posts: 75
Joined: Sun Mar 11, 2012 11:28 pm
Has thanked: 3 times
Been thanked: 5 times

Re: JSON-OBJECT/From-FILE  [SOLVED]

Post by danny »

yup :-) u can parse json direct in proclaim maths now
keywords dropdown in proclaim editor gives the syntax

not used it but looks like u form a named JSON array from a json string using JSON-ARRAY("myobj", "{some json:here,orAFieldcontaining:json}")
u then operate on that json, with the other commands
JSON-ARRAY-FIRST("myobj")
etc - usual FIRST LAST looping etc

u might have webservice or httpservice that returns json (u can set accept type of httpservice to JSON and store in alpha field) which u store in a file or in a database field. looks like code lets u load from a file or from field or variable as needed

thatt post u link is from 2014 so well old

REST services too lets u consume webservice and use json templates which might be easier

Code Killer
Posts: 45
Joined: Thu Oct 29, 2015 10:04 am
Location: Kent
Has thanked: 33 times
Been thanked: 3 times

Re: JSON-OBJECT/From-FILE

Post by Code Killer »

Great, we're in the process of upgrading to 3.4 at the moment so I'll be having a good look at that.

It's good that that's now inbuilt and opens a lot of doors especially combined with REST. :geek:

It's strange how this hasn't been a bigger talking point on the forums since these extra functions have been added with the amount of potential it brings. :?

Thanks for the info :D

revellbikes
Posts: 488
Joined: Fri Jun 15, 2012 12:44 pm
Has thanked: 16 times
Been thanked: 51 times

Re: JSON-OBJECT/From-FILE

Post by revellbikes »

Anyone any thoughts on whether this could be utilised on an Import / Export type basis? I've been trying to figure out if it's possible for some time to Import a JSON file from a directory to create a new case from a Website form.

Obviously the rest services program won't work in my scenario as I need Proclaim to poll for new files in a directory, I.e directory monitoring. Then process any files that appear.

Sounds like the maths functions would work IF I knew the name of the file to import... Sadly though I don't think that will be possible as I'd need to be able to pickup the first lt file in the folder, then perform the create case function and then delete or move the file.

Any thoughts much appreciated!

steve
Posts: 470
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 120 times

Re: JSON-OBJECT/From-FILE

Post by steve »

revellbikes wrote:
Sat Jun 06, 2020 11:52 am
Anyone any thoughts on whether this could be utilised on an Import / Export type basis? I've been trying to figure out if it's possible for some time to Import a JSON file from a directory to create a new case from a Website form.
Can you control the filenames produced by your website form and get them into IMDMv2 format?
AABBBBB_CCCCC.json
where
AA = IM phrase (two alphanumeric chars)
BBBBB = a single case reference created solely for processing imports
_CCCC = any string to make the filename unique
?
Alternatively, can you create and run a script that runs on the directory, that produces a file listing in json itself - e.g. https://stackoverflow.com/questions/432 ... -json-with? If so you could hack something together I think...