thedbpro Posted September 7, 2018 Share Posted September 7, 2018 Hi Everyone, I've got a JSON issue that I've been struggling to figure out. Here is a sample output of what I'm trying to do: { "fulfillment": { "location_id": 905684977, "tracking_numbers": [ "a4e6e7ca452c7873c2ef10234d042352", "81669206ee8e6164da5ac190af93e6ca", "3def69908a9530b5c46b282a988cf914" ], "line_items": [ { "id": 466157049 }, { "id": 518995019 }, { "id": 703073504 } ] } } It's the "tracking_numbers" that is throwing me off. I can build normal arrays like "line_items" no problem, but I've no idea how to structure the JSONSetElement function in a way that gives me multiple values for a single key as seen in "tracking_numbers". Any help would be greatly appreciated! Link to comment Share on other sites More sharing options...
thedbpro Posted September 7, 2018 Author Share Posted September 7, 2018 I figured it out. Here is the code that gets the job done. JSONSetElement ( $$json ; ["tracking_numbers[0]" ; "4324234" ; JSONString]; ["tracking_numbers[1]" ; "2342342" ; JSONString] ) Link to comment Share on other sites More sharing options...
rwoods Posted September 7, 2018 Share Posted September 7, 2018 Hello Just looking at the documentation it says :- You can set multiple elements by providing an additional set of keyOrIndexOrPath, value, and type parameters in brackets [ ] for each element. The following syntax sets N elements at once: JSONSetElement ( json ; [ keyOrIndexOrPath1 ; value1 ; type1 ] ; [ keyOrIndexOrPath2 ; value2 ; type2 ] ; ... [ keyOrIndexOrPathN ; valueN ; typeN ] ) Does that help Exactly! We over-lapped there.... 1 Link to comment Share on other sites More sharing options...
thedbpro Posted September 7, 2018 Author Share Posted September 7, 2018 57 minutes ago, rwoods said: ..... Exactly! We over-lapped there.... Overlapped indeed! I appreciate you taking the time to answer nonetheless! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 2030 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now