read Data from JSONBuilder

Hi,

 

with Object of JSONBuilder we can simply create Data in JSON-Format. Is there also a simple way/Class in reverse direction to read JSON-Format String to get all data from its different Fields? Othrwise I must do it with String.

 

Thanks!

RE: read Data from JSONBuilder

Hi Jianchun,

Have you looked at the struct documentation? It demonstrates how to build up a struct from JSON.

If this is not what you mean, could you provide a pseudo example of what you mean?

Best regards.

By: Tony Yates 23 Feb 2021

RE: read Data from JSONBuilder

Hi Tony,

 

we implement Data Exchange via File Exchange between SuperOffice and SBO (SAP Business One). from SBO we must update its data in SO based on its SO Customer number. For examle I got this File from SBO:

{"Export Debitor": {"Nummer": "15122","Debitornummer": "506115122","Id": 4818,"Name": "DREWTUR JACEK GUGAŁA I ANETA GUGAŁA SPÓŁKA JAWNA","Name2": "PRZEDSIĘBIORSTWO PRODUKCYJNO-USŁUGOWE DREWTUR JACEK GUGAŁA I ANETA GUGAŁA SPÓŁKA JAWNA","Postadresse Strasse": "Turkowy 6","Postadresse Ort": "Perzów","Postadresse PLZ": "63-642","Besucheradresse Strasse": "Turkowy 6","Besucheradresse Ort": "","Besucheradresse PLZ": "","Land": "Polen","Telefon": "48 601 758 605","Fax": "","Email": "","Website": "","Verantwortlich": "Krzysztof Jagiela","Kategorie": "Kunde","ustId": "PL6191770159","Steuernummer": "","Kreditversicherung (Euro)": "0","Zahungsbedingung": "Vorkasse","Relevant für Intrastat": "False","Incoterms": ""}

I must update this in SO based on its number 15122. It is not to solve with struct, normally I must dissolve this String with String Methode after(p), before(p), I just thoutht maybe there is a simple Class in library to dissolve this String in JSON-Format.

 

Thanks!

By: Jianchun You 23 Feb 2021

RE: read Data from JSONBuilder

Hi,

Yes, CRMScript has a JSON parser. There is a parseJSON(string) method that gives you a XMLNode (nevermind the lousy naming, it is the root node of the JSON). Then you can use XMLNode.getValueFromPath(string) to get the value you want.

Sverre

By: Sverre Hjelm 23 Feb 2021

RE: read Data from JSONBuilder

Hi Sverre,

 

that's good idea! I found it. Thanks!

By: Jianchun You 23 Feb 2021

RE: read Data from JSONBuilder

Note: Would suggest to use parseJSON2, parseJSON has a nasty issue that it will still return a single node even when the json is empty.

By: David Hollegien 23 Feb 2021

RE: read Data from JSONBuilder

Hi David, ok,. Thanks! I will check this.

By: Jianchun You 23 Feb 2021