JSON Build tool bug
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I'm trying to build some JSON for sending tracking data to FedEx API.
The JSON build tool is extremely basic, it isn't able to do much. But it did seem like it would be handy to combine the array of up to 30 tracking numbers into one request. But it appears it isn't capable of that unless I'm doing something non-obvious wrong, or there is a workaround.
First I'm manually building the tracking number key value pair in JSON format since the Build tool can't do that - it just turns it into a massive non-breaking string.
The output is correct if I put a browse tool on it and copy/paste into Notepad++
{
"trackingNumberInfo": {
"trackingNumber": "613746411451"
}
}
But as I try to use it to concatenate the request together, the JSON Build tool is deleting the carriage return/line feed control characters and replacing them with the new line escape character.
{"trackingInfo":" {\n \"trackingNumberInfo\": {\n \"trackingNumber\": \"613746411451\"\n }\n }","trackingInfo":" {\n \"trackingNumberInfo\": {\n \"trackingNumber\": \"613746411452\"\n }\n }"}
Trying to figure out workarounds for all this is really exhausting and time consuming.
Does anyone know a way to deal with this? I guess I could see if I could replace the \n characters with the control characters again.
- Labels:
- API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
you are over thinking this. Json build tool is expecting to recieve key/value paris as basic data so:
key= field
value = value
and returns {"key":"value"}
- you are feeding in preformatted Json - you can do that if you are using something nested - but if you'd nest Json you'd use escape chracters -so that's what its doing.
if you already have the Json in a string field and in a single row for each api call - you can skip the json build tool and just feed it into the download tool...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes and I did that at first with the lowest level of the key data elements of "trackingNumber".
But since the JSON Build tool can't seemingly do proper formatting or nesting, or do the 2nd level key of "trackingNumberInfo" on its own, I had to build the array elements myself in a formula. Then I thought to try using the JSON Build tool to concatenate (with it's grouping capability) the preformatted JSON elements into the maximum array size that FedEx allows of 30 records for the "trackingInfo" element in one API submission.
If the JSON Build tool could do this correctly it would be very handy for that use case, as I could use a Tile tool on all of my tracking number data inputs, and have the JSON Build tool automatically group the requests into buckets of submittable 30 units. But it seems it can't even do that without wrecking carriage returns. Hopefully I can figure out a way to get the same result with more work using the Summarize tool with concatenate, and more manual manipulation of the opening and closing elements of the JSON.
This is an example of the JSON that FedEx expects, up to 30 elements.
{
"trackingInfo": [
{
"trackingNumberInfo": {
"trackingNumber": "Tracking Number 1"
}
},
{
"trackingNumberInfo": {
"trackingNumber": "Tracking Number 2"
}
},
{
"trackingNumberInfo": {
"trackingNumber": "Tracking Number 3"
}
}
],
"includeDetailedScans": true
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
does it look any better if your formula tool uses a single line? but yeah - I don't really use that tool just because I think formula/summarize whatever is cleaner and gives me more granular control of my json.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Well I don't think it matters in JSON, but I was trying to do a character perfect implementation of it from what works in Postman. The carriage returns and free space also greatly helps troubleshooting the enevitable mistakes I make. I've been working on another API for another company and if the POST body had all been on one string it would have taken much longer to troubleshoot problems.
I guess I was just surprised by how limiting the JSON Build tool was. It is easier for the individual data elements to just create it in a formula, and the JSON Build tool seemingly can't help with any of the more complex nesting/opening/closing either. Then when it was messing up the carriage returns, I was wondering if I was missing something. I'm not sure where this tool would be useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
yeah - I think I see it as a continuum like:
1) input data with- > json
DOESN'T WORK. what the hell - how is this possible?
2) xml tools - really useless
3) Json build tool - mostly useless
4) Json parse tool - usually decent
