I am wondering if the attached image that represents how JSON data is returned from a stock market API is improperly formatted JSON data.
Here is a link to the API call that the image pictorially represents: https://api.iextrading.com/1.0/stock/market/batch?symbols=A,AAPL&types=chart&range=1d
The API call essentiall returns market data for 1 day of both stock symbol A and AAPL (as an example). However, I thought JSON is typically [{}, {}, {}] or {[{}, {}]} format but this API batch request is {{[{}, {}]}}.
Would be much appreciated is someone could provide some insight.
Related
I have a web-hook that calls an API that returns a single plain text response. The response isn't formatted in JSON or xml because the response is a single piece of data, not a map or array. I see plenty of examples of how to extract a field from a JSON response and store it in a marketo token but no example of how to store the whole response payload. Here is a sample response from the API:
alsdfjasdhfalksdhfalksdjalksdk
Note that the response is not anything like this:
{
"field":"alsdfjasdhfalksdhfalksdjalksdk"
}
Maybe some Marketo expert has done this and could share. I'd appreciate it, thanks.
Marketo's parsing of XML and JSON is limited, to say the least--so your webhook does need to declare some sort of key-value pair so the response can be mapped. Given what you're describing, you could likely just hardcode in the surrounding JSON with the right MIME type and be fine.
Basically, Marketo can only handle the following for JSON webhook responses:
Key-value pair
Key can only be defined by placement (no XPath or similar--you'd be stuck with field[1] or similar)
Ideally no nesting, as Marketo doesn't do a great job of reading nested data--largely for the reason mentioned above
I'm currently working with JSON API data which updated daily by my data team. I only need to extract certain information from the JSON file using pandas. So I managed to transform the data by pulling 1 sample JSON file from the API provided. However, I also need to update the transformed data in pandas with other JSON files from the API and I'm stuck here. FYI the JSON files from the API contain in folders name by according to date pulled
The following is the code I used to pull 1 sample JSON data for the transformation process.
#pull 1 sample data from API
df = requests.get('http://phpweb.123.co/atz-pull/output/2019-07-30/abc123.json').json()
So I managed to transform the data into the form i required. However I need to update the transformed data with other json files from different date folders.
Let say the output folders from the api also consist of the following (note that the json file name is unique ;
/output/2019-07-30/abc456.json
/output/2019-07-30/def678.json
/output/2019-07-29/wef678.json
Appreciate helps
My boss told me to compare json response and automate it. For eg: Store the json response which are coming from server and store them in one file now make second file to call first file and compare each json response. If response is right then automatically it will check mark saying "all response are correct" and vice versa. But I don't know how to do it. Can anyone guide me ?
So I want to be able to run this
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address
which returns a json response with many results...
Id like to be able to parse the json from the url itself...
so something like. ....
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&result_type=street_address&results[0].formatted_address
so that instead of getting a multiline response - I just get what I need in a single line such as...
277 Bedford Avenue, Brooklyn, NY 11211, USA
Sure I can write a script to do this but I wonder if specific fields of the JSON are restful.
Am i talking smack or is this possible ?
Thank You
Although RESTful web services may utilize JSON, the fields of JSON results themselves are not RESTful. Parsing values from the URL would probably require you to change how Google handles url processing on the server end. You'll have to get that information programmatically.
So I am parsing the www.twitch.tv API json page.
Here is the link: (these 2 people are normally always streaming - if the json data shows as [] it means they are offline. if someone is offline, json has no data)
http://api.justin.tv/api/stream/list.json?channel=vokemodels
http://api.justin.tv/api/stream/list.json?channel=mathmind
My problem is that in my iOS application, I can do:
[dictionary objectForKey:#"stream_count"]];
And I do successfully get data from the JSON and it will log correctly. However, when trying to get data from the "screen_cap_url_medium" key, I do the following code:
[dictionary objectForKey:#"screen_cap_url_medium"]];
And I get a (null) when logging. I am absolutely positive I am retrieving the JSON data, and I do not have any typos.
When I NSLog the entire JSON array from one of the above links, the "screen_cap_url_medium" is one of the only keys that are in quotes.
Can anyone tell me what I'm doing wrong?
If you inspect your json you'll see that screen_cap_url_medium is under channel object, so you can access it like this:
[dictionary valueForKeyPath:#"channel.screen_cap_url_medium"];
PS. Here dictionary is obviously the first object of the root array you get back from your response.