Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

How to find the format type(xml,json,csv) from incoming dataset in windows service?

$
0
0

Iam trying to create a  windows service,that should get data for every one minute from REST API ( for ex,open weather map site)or Applications or Device API.The data format may be 

Xml

json

csv

Text

If  incoming data is json it may be look like following(Without any content type header)

{"cnt":20,"list":[{"coord":{"lon":77.6,"lat":12.98},"sys":{"type":1,"id":7821,"message":0.0114,"country":"IN","sunrise":1503275880,"sunset":1503320823},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"main":{"temp":301.63,"pressure":1006,"humidity":58,"temp_min":301.15,"temp_max":302.15},"visibility":10000,"wind":{"speed":7.2,"deg":240},"clouds":{"all":40},"dt":1503316670,"id":1277333,"name":"Bangalore"}]}}

I can expect data set with out content type header.

if incoming data is json i can directly push into the IOT Hub

If it is XML or Text i have to convert it as a json and then i have to push the data to IOT Hub.

How can i find which type of data is coming ?


Viewing all articles
Browse latest Browse all 555

Trending Articles