![]() You can see the example code piece below. For clarification, The JSON body holds data from Maximo objects which will be sent to the external system to create associated records there.įor single objects we use JSONObject alone which is an easy task. I needed to send a JSON formatted text as the body of an http POST request. My starting point for this exercise was the requirement of a REST client implemented on Maximo for an external REST service. More information on JSON and JSON4J library can be found via the link below: Then you just: var data = JsonConvert.Maximo framework includes json4j.jar library for JSON implementations such as constructing JSON formatted data, XML to JSON conversions, JSON string and stream parsing etc. So, your DTO classes could look something like this: public class Data One advantage of using classes instead of dynamic is that you get Intellisense. You can do this by creating classes for each set and specifying the field names that come in the JSON data with Quick and dirty, and it will probably work - but there's got to be a more elegant method, right? Note: All else fails I'll probably be manipulating strings for the square brackets containing the "Stock Quotes" children, then parsing those, and so on. The goal is to throw each child element into a dictionary of objects of a custom class.Īny help is greatly appreciated, thank you! I'm just not sure of the syntax I need to use to grab each child element. The object contains a count method that shows how many child elements "Stock Quotes" has. I need the all the children of the second child, "Stock Quotes". Which seems to create some generic object with 2 children. ![]() So far I've tried: dynamic obj = JsonConvert.DeserializeObject(rawJSON) So the "Stock Quotes" array is what I need to grab every time, and the number of elements within the array are dependent upon in the input by user. ![]() Notes": "IEX Real-Time Price provided for free by IEX ().", ![]() Information": "Batch Stock Market Quotes", However, now the batch quote API is returning an dynamic number of stocks at once, I can't quite crack the syntax. I'm using Newtonsoft to parse my old API call, which returns a very predictable output. They have since released a "batch quote" feature that could actually save lot of work in my application. ![]() My market API service discontinued the call I was using to grab data into my C# application. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |