简体   繁体   中英

Suitescript, nlapiRequestURL, can't turn a JSON from a URL into an object/array

In netsuite i'm using the nlapiRequestURL to retrieve a JSON data from flexport, an overseas shipping company. I have have the data as a string(to my knowledge retrieving json data makes it a string) and want to turn it into an array of objects, but everything I have tried has resulted in various errors.

trying...

       `var output = nlapiRequestURL(url,null,headers,"GET");
        var split = JSON.parse(output.getBody());
        response.write(split);`  

gave me
{records=[Ljava.lang.Object;@7220fad}
and trying to show any element of split gave me undefined or that it cant read element from index. I've ran the string through a JSON checker and it said it was a valid JSON file. I've done various variations of JSON.parse and looked tried Tostring. I've been working on this for a while and have no idea why I can't parse this information properly. Any help is appreciated.

You have parsed the result but then you are writing the parsed object which just gets you the object's implementation dependent toString() output.

If you are just trying to echo the response re-stringify the parsed payload.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM