Sample data for a JSON type provider with an additional property

I am trying to use a JSON type provider to access StackOverflow / StackExchange data through an API. It works great, with one caveat. The API has a throttle, which is signaled by a β€œdelay” field, which contains the number of seconds that you must retreat before the next request. As a result, I cannot just point the TP JSON to the url, because by default the backoff field is missing. This is what the answer usually looks like:

{ "items": [ { "has_synonyms": true, "user_id": 1144035, "is_moderator_only": false, "is_required": false, "count": 7054, "name": "sql" }, { "has_synonyms": true, "user_id": 1144035, "is_moderator_only": false, "is_required": false, "count": 16, "name": "algorithm" } ], "has_more": true, "quota_max": 10000, "quota_remaining": 9693 } 

I suggested that I needed to provide a sample that contains both a non-deferred example (as mentioned above) and one line by line:

  "has_more": true, "quota_max": 10000, "quota_remaining": 9693, "backoff": 10 } 

... so I get the Backoff option. However, I am not sure how to structure / prepare the sample for this effect. Help would be greatly appreciated!

+6
source share
1 answer

The JSON type provider has the SampleIsList property, set it to true .
There is a Parsing Twitter stream documentation section here, JsonProvider scroll down the page since there is no way to directly link to the section.

Your sample file should look like this

 [{ ... "has_more": true, "quota_max": 10000, "quota_remaining": 9693 },{ ... "has_more": true, "quota_max": 10000, "quota_remaining": 9693, "backoff": 10 }] 
+4
source

Source: https://habr.com/ru/post/983626/


All Articles