Hi Guys, I know this has been discussed before but...
# suitescript
k
Hi Guys, I know this has been discussed before but with looking and looking i cannot find anything about it anywhere. I'm looking for the XML to JSON Custom Module compatible to use within NetSuite server side scripts. If any one has the reference to this I would be most grateful.
s
JSONIX remains my go-to for bidirectional JS->XML serialization, though I had to tweak it a bit to work in NS.
k
You going to let me be cheeky and ask if you could ping me a copy? lol
s
These are the base files, plus SOAP in case your XML is related to a SOAP web service - if not you can ignore the SOAP* files. Otherwise the rest go into your file cabinet. You still need to define/generate your mapping file per standard JSONIX use.
k
Gotta be honest i assumed that it would just be one file to add as a custom module
also looking in the zip how would i go about adding it into the NAMD config path with all those files?
s
I don't use NAMD config at all, ever. It's braindead in NS.
use relative paths.
k
braindead? lol
s
NetSuite's implementation of that config only works with top level script files - which makes it fairly useless imho
JSONIX normally ships as a single bundled file - but to make it work with NS's module system I had to break out the dependencies as shown.
k
OK thanks I'll figure it out.
s
Assuming you're using SDF, whether it's one file or split into several shouldn't make a difference. Just imagine it's one file 🙂
k
yeah always SDF. going to try my luck with xml2js for starters as one file and need the strtojson
s
good luck. One killer feature of JSONIX is it is able to map very flexibly from JSON<->XML so you don't have to bend your JSON or the XML to fit the library.
most of the other libraries I saw either had limited support for XML constructs or forced your JSON to a particular shape or special syntax
k
@stalbert not really found another that does a good job. Have tried to work out how to use this in a UE but failed. Do you have the correct usage and how to use?
s
the JSONIX wiki has a lot of info. If you have XSDs defining the XML you can generate the mapping with the jsonix jar file
k
Ah I don’t have an XSD just need to convert an XML file to JSON to then use the data to create and update records
s
you can manually create the JSONIX mapping then, or use some tool to generate an XSD from your XML file....