Json Api values 0 or falseparse json response c#How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

Does Doodling or Improvising on the Piano Have Any Benefits?

How to preserve electronics (computers, iPads and phones) for hundreds of years

Pre-mixing cryogenic fuels and using only one fuel tank

Why is it that I can sometimes guess the next note?

How to get directions in deep space?

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

US tourist/student visa

Stack Interview Code methods made from class Node and Smart Pointers

Permission on Database

Taxes on Dividends in a Roth IRA

Which Article Helped Get Rid of Technobabble in RPGs?

Did the UK lift the requirement for registering SIM cards?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Why Shazam when there is already Superman?

A variation to the phrase "hanging over my shoulders"

What is the highest possible scrabble score for placing a single tile

How to convince somebody that he is fit for something else, but not this job?

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

When were female captains banned from Starfleet?

Why does Carol not get rid of the Kree symbol on her suit when she changes its colours?

What does Apple's new App Store requirement mean

Is my low blitz game drawing rate at www.chess.com an indicator that I am weak in chess?

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?



Json Api values 0 or false


parse json response c#How do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How to parse JSON in JavaWhy does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?













-1















I am using a web JSON api to provide some values from a game market into c# objects. I am fairly new to c# and haven't worked with API's before.



Heres my code:



using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace HttpsApiTest

class Program


public class ForQuery

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Buy

public static ForQuery forQuery get; set;
public static long volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class ForQuery2

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Sell

public ForQuery2 forQuery get; set;
public static int volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class RootObject

public Buy buy get; set;
public Sell sell get; set;


static void Main(string[] args)

string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
string sLine = objReader.ReadLine();

JToken.Parse(sLine.Replace("[", "").Replace("]", "")).ToObject<RootObject>();

Console.WriteLine(Buy.max);
Console.WriteLine(Buy.highToLow);

Console.ReadLine();





and the web api JSON outputs this:



[

"buy":
"forQuery":
"bid": true,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 5544790080,
"wavg": 11.43,
"avg": 10.86,
"variance": 4.38,
"stdDev": 2.09,
"median": 12,
"fivePercent": 13.75,
"max": 20,
"min": 5,
"highToLow": true,
"generated": 1551926105235
,
"sell":
"forQuery":
"bid": false,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 258207299,
"wavg": 16.8,
"avg": 20.21,
"variance": 132.71,
"stdDev": 11.52,
"median": 15.99,
"fivePercent": 12.92,
"max": 60,
"min": 6,
"highToLow": false,
"generated": 1551926105235


]


I am not sure why Console.WriteLine(Buy.max); shows as 0 instead of 20 and Console.WriteLine(Buy.highToLow); shows as false instead of true. what am I doing wrong? I have looked for solutions to this issue for the past few hours to no avail. Any help would be greatly appreciated!










share|improve this question

















  • 1





    Why are all your properties static? Try removing static from properties.

    – AliK
    Mar 7 at 4:56






  • 1





    Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

    – Jimi
    Mar 7 at 5:07












  • Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

    – Jimi
    Mar 7 at 5:13












  • I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

    – Parker Allen
    Mar 7 at 17:32















-1















I am using a web JSON api to provide some values from a game market into c# objects. I am fairly new to c# and haven't worked with API's before.



Heres my code:



using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace HttpsApiTest

class Program


public class ForQuery

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Buy

public static ForQuery forQuery get; set;
public static long volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class ForQuery2

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Sell

public ForQuery2 forQuery get; set;
public static int volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class RootObject

public Buy buy get; set;
public Sell sell get; set;


static void Main(string[] args)

string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
string sLine = objReader.ReadLine();

JToken.Parse(sLine.Replace("[", "").Replace("]", "")).ToObject<RootObject>();

Console.WriteLine(Buy.max);
Console.WriteLine(Buy.highToLow);

Console.ReadLine();





and the web api JSON outputs this:



[

"buy":
"forQuery":
"bid": true,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 5544790080,
"wavg": 11.43,
"avg": 10.86,
"variance": 4.38,
"stdDev": 2.09,
"median": 12,
"fivePercent": 13.75,
"max": 20,
"min": 5,
"highToLow": true,
"generated": 1551926105235
,
"sell":
"forQuery":
"bid": false,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 258207299,
"wavg": 16.8,
"avg": 20.21,
"variance": 132.71,
"stdDev": 11.52,
"median": 15.99,
"fivePercent": 12.92,
"max": 60,
"min": 6,
"highToLow": false,
"generated": 1551926105235


]


I am not sure why Console.WriteLine(Buy.max); shows as 0 instead of 20 and Console.WriteLine(Buy.highToLow); shows as false instead of true. what am I doing wrong? I have looked for solutions to this issue for the past few hours to no avail. Any help would be greatly appreciated!










share|improve this question

















  • 1





    Why are all your properties static? Try removing static from properties.

    – AliK
    Mar 7 at 4:56






  • 1





    Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

    – Jimi
    Mar 7 at 5:07












  • Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

    – Jimi
    Mar 7 at 5:13












  • I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

    – Parker Allen
    Mar 7 at 17:32













-1












-1








-1








I am using a web JSON api to provide some values from a game market into c# objects. I am fairly new to c# and haven't worked with API's before.



Heres my code:



using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace HttpsApiTest

class Program


public class ForQuery

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Buy

public static ForQuery forQuery get; set;
public static long volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class ForQuery2

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Sell

public ForQuery2 forQuery get; set;
public static int volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class RootObject

public Buy buy get; set;
public Sell sell get; set;


static void Main(string[] args)

string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
string sLine = objReader.ReadLine();

JToken.Parse(sLine.Replace("[", "").Replace("]", "")).ToObject<RootObject>();

Console.WriteLine(Buy.max);
Console.WriteLine(Buy.highToLow);

Console.ReadLine();





and the web api JSON outputs this:



[

"buy":
"forQuery":
"bid": true,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 5544790080,
"wavg": 11.43,
"avg": 10.86,
"variance": 4.38,
"stdDev": 2.09,
"median": 12,
"fivePercent": 13.75,
"max": 20,
"min": 5,
"highToLow": true,
"generated": 1551926105235
,
"sell":
"forQuery":
"bid": false,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 258207299,
"wavg": 16.8,
"avg": 20.21,
"variance": 132.71,
"stdDev": 11.52,
"median": 15.99,
"fivePercent": 12.92,
"max": 60,
"min": 6,
"highToLow": false,
"generated": 1551926105235


]


I am not sure why Console.WriteLine(Buy.max); shows as 0 instead of 20 and Console.WriteLine(Buy.highToLow); shows as false instead of true. what am I doing wrong? I have looked for solutions to this issue for the past few hours to no avail. Any help would be greatly appreciated!










share|improve this question














I am using a web JSON api to provide some values from a game market into c# objects. I am fairly new to c# and haven't worked with API's before.



Heres my code:



using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace HttpsApiTest

class Program


public class ForQuery

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Buy

public static ForQuery forQuery get; set;
public static long volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class ForQuery2

public static bool bid get; set;
public static List<int> types get; set;
public static List<object> regions get; set;
public static List<object> systems get; set;
public static int hours get; set;
public static int minq get; set;


public class Sell

public ForQuery2 forQuery get; set;
public static int volume get; set;
public static double wavg get; set;
public static double avg get; set;
public static double variance get; set;
public static double stdDev get; set;
public static double median get; set;
public static double fivePercent get; set;
public static double max get; set;
public static double min get; set;
public static bool highToLow get; set;
public static long generated get; set;


public class RootObject

public Buy buy get; set;
public Sell sell get; set;


static void Main(string[] args)

string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
string sLine = objReader.ReadLine();

JToken.Parse(sLine.Replace("[", "").Replace("]", "")).ToObject<RootObject>();

Console.WriteLine(Buy.max);
Console.WriteLine(Buy.highToLow);

Console.ReadLine();





and the web api JSON outputs this:



[

"buy":
"forQuery":
"bid": true,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 5544790080,
"wavg": 11.43,
"avg": 10.86,
"variance": 4.38,
"stdDev": 2.09,
"median": 12,
"fivePercent": 13.75,
"max": 20,
"min": 5,
"highToLow": true,
"generated": 1551926105235
,
"sell":
"forQuery":
"bid": false,
"types": [
1230
],
"regions": [],
"systems": [],
"hours": 24,
"minq": 1
,
"volume": 258207299,
"wavg": 16.8,
"avg": 20.21,
"variance": 132.71,
"stdDev": 11.52,
"median": 15.99,
"fivePercent": 12.92,
"max": 60,
"min": 6,
"highToLow": false,
"generated": 1551926105235


]


I am not sure why Console.WriteLine(Buy.max); shows as 0 instead of 20 and Console.WriteLine(Buy.highToLow); shows as false instead of true. what am I doing wrong? I have looked for solutions to this issue for the past few hours to no avail. Any help would be greatly appreciated!







c# json parsing console-application






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 4:50









Parker AllenParker Allen

32




32







  • 1





    Why are all your properties static? Try removing static from properties.

    – AliK
    Mar 7 at 4:56






  • 1





    Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

    – Jimi
    Mar 7 at 5:07












  • Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

    – Jimi
    Mar 7 at 5:13












  • I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

    – Parker Allen
    Mar 7 at 17:32












  • 1





    Why are all your properties static? Try removing static from properties.

    – AliK
    Mar 7 at 4:56






  • 1





    Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

    – Jimi
    Mar 7 at 5:07












  • Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

    – Jimi
    Mar 7 at 5:13












  • I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

    – Parker Allen
    Mar 7 at 17:32







1




1





Why are all your properties static? Try removing static from properties.

– AliK
Mar 7 at 4:56





Why are all your properties static? Try removing static from properties.

– AliK
Mar 7 at 4:56




1




1





Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

– Jimi
Mar 7 at 5:07






Why are you're trying to remove pieces of the JSON. Don't do that. It's a valid JSON. Read the stream to the end the deserialize to a simpler class structure. Your Buy and Sell classes are identical, so is the ForQuery class. You can have just one type of each. You could just use the Properties names (Buy and Sell) to tell apart the two objects. That's all.

– Jimi
Mar 7 at 5:07














Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

– Jimi
Mar 7 at 5:13






Also, you can use an attribute [JsonProperty("[OriginalPropertyName]")] if you need to change the name of a property.

– Jimi
Mar 7 at 5:13














I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

– Parker Allen
Mar 7 at 17:32





I used static because the way my code was setup, it threw an error saying it couldn't use a non-static value.

– Parker Allen
Mar 7 at 17:32












3 Answers
3






active

oldest

votes


















0














What they said:



  • Static members are usually for helpers or factory methods, or constants

  • The API is returning an array (or List)

  • That string-foo replacement is just sketchy at best. Any time you are working with a standard like JSON or XML, use the libraries to convert it to an object, then manipulate

Here's a working snippet:



using System;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace HttpsApiTest

class Program


public class ForQuery

public bool bid get; set;
public List<int> types get; set;
public List<object> regions get; set;
public List<object> systems get; set;
public int hours get; set;
public int minq get; set;


public class Buy

public ForQuery forQuery get; set;
public long volume get; set;
public double wavg get; set;
public double avg get; set;
public double variance get; set;
public double stdDev get; set;
public double median get; set;
public double fivePercent get; set;
public double max get; set;
public double min get; set;
public bool highToLow get; set;
public long generated get; set;


public class ForQuery2

public bool bid get; set;
public List<int> types get; set;
public List<object> regions get; set;
public List<object> systems get; set;
public int hours get; set;
public int minq get; set;


public class Sell

public ForQuery2 forQuery get; set;
public int volume get; set;
public double wavg get; set;
public double avg get; set;
public double variance get; set;
public double stdDev get; set;
public double median get; set;
public double fivePercent get; set;
public double max get; set;
public double min get; set;
public bool highToLow get; set;
public long generated get; set;


public class RootObject

public Buy buy get; set;
public Sell sell get; set;


static void Main(string[] args)

string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
string sLine = objReader.ReadLine();

var obj = JToken.Parse(sLine).ToObject<List<RootObject>>();

Console.WriteLine("Buy node:");

Console.WriteLine(" Max: " + obj[0].buy.max);
Console.WriteLine(" HighToLow: " + obj[0].buy.highToLow);

Console.WriteLine("Sell node:");

Console.WriteLine(" Max: " + obj[0].sell.max);
Console.WriteLine(" HighToLow: " + obj[0].sell.highToLow);

Console.ReadLine();








share|improve this answer























  • This worked perfectly! Thank you!

    – Parker Allen
    Mar 7 at 17:32


















0














The string replace is going to remove all instances of square brackets. You'd be better off deserializing the response as a list of RootObjects.






share|improve this answer






























    0














    class Data

    public string DataPoint;


    class CustomData

    public Data Dp;


    class Utility

    public T JsonDeserialisation<T>(string jsonFile)

    TextReader textReader = new StreamReader(jsonFile);
    JsonTextReader jsonReader = new JsonTextReader(textReader);
    return JsonSerializer.CreateDefault().Deserialize<T>(jsonReader);




    Since you have all classes beforehand, you can the following code generic json deserializer. Here 'T' is CustomData class






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036305%2fjson-api-values-0-or-false%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      What they said:



      • Static members are usually for helpers or factory methods, or constants

      • The API is returning an array (or List)

      • That string-foo replacement is just sketchy at best. Any time you are working with a standard like JSON or XML, use the libraries to convert it to an object, then manipulate

      Here's a working snippet:



      using System;
      using System.Net;
      using System.IO;
      using Newtonsoft.Json.Linq;
      using System.Collections.Generic;

      namespace HttpsApiTest

      class Program


      public class ForQuery

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Buy

      public ForQuery forQuery get; set;
      public long volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class ForQuery2

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Sell

      public ForQuery2 forQuery get; set;
      public int volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class RootObject

      public Buy buy get; set;
      public Sell sell get; set;


      static void Main(string[] args)

      string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
      StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
      string sLine = objReader.ReadLine();

      var obj = JToken.Parse(sLine).ToObject<List<RootObject>>();

      Console.WriteLine("Buy node:");

      Console.WriteLine(" Max: " + obj[0].buy.max);
      Console.WriteLine(" HighToLow: " + obj[0].buy.highToLow);

      Console.WriteLine("Sell node:");

      Console.WriteLine(" Max: " + obj[0].sell.max);
      Console.WriteLine(" HighToLow: " + obj[0].sell.highToLow);

      Console.ReadLine();








      share|improve this answer























      • This worked perfectly! Thank you!

        – Parker Allen
        Mar 7 at 17:32















      0














      What they said:



      • Static members are usually for helpers or factory methods, or constants

      • The API is returning an array (or List)

      • That string-foo replacement is just sketchy at best. Any time you are working with a standard like JSON or XML, use the libraries to convert it to an object, then manipulate

      Here's a working snippet:



      using System;
      using System.Net;
      using System.IO;
      using Newtonsoft.Json.Linq;
      using System.Collections.Generic;

      namespace HttpsApiTest

      class Program


      public class ForQuery

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Buy

      public ForQuery forQuery get; set;
      public long volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class ForQuery2

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Sell

      public ForQuery2 forQuery get; set;
      public int volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class RootObject

      public Buy buy get; set;
      public Sell sell get; set;


      static void Main(string[] args)

      string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
      StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
      string sLine = objReader.ReadLine();

      var obj = JToken.Parse(sLine).ToObject<List<RootObject>>();

      Console.WriteLine("Buy node:");

      Console.WriteLine(" Max: " + obj[0].buy.max);
      Console.WriteLine(" HighToLow: " + obj[0].buy.highToLow);

      Console.WriteLine("Sell node:");

      Console.WriteLine(" Max: " + obj[0].sell.max);
      Console.WriteLine(" HighToLow: " + obj[0].sell.highToLow);

      Console.ReadLine();








      share|improve this answer























      • This worked perfectly! Thank you!

        – Parker Allen
        Mar 7 at 17:32













      0












      0








      0







      What they said:



      • Static members are usually for helpers or factory methods, or constants

      • The API is returning an array (or List)

      • That string-foo replacement is just sketchy at best. Any time you are working with a standard like JSON or XML, use the libraries to convert it to an object, then manipulate

      Here's a working snippet:



      using System;
      using System.Net;
      using System.IO;
      using Newtonsoft.Json.Linq;
      using System.Collections.Generic;

      namespace HttpsApiTest

      class Program


      public class ForQuery

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Buy

      public ForQuery forQuery get; set;
      public long volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class ForQuery2

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Sell

      public ForQuery2 forQuery get; set;
      public int volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class RootObject

      public Buy buy get; set;
      public Sell sell get; set;


      static void Main(string[] args)

      string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
      StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
      string sLine = objReader.ReadLine();

      var obj = JToken.Parse(sLine).ToObject<List<RootObject>>();

      Console.WriteLine("Buy node:");

      Console.WriteLine(" Max: " + obj[0].buy.max);
      Console.WriteLine(" HighToLow: " + obj[0].buy.highToLow);

      Console.WriteLine("Sell node:");

      Console.WriteLine(" Max: " + obj[0].sell.max);
      Console.WriteLine(" HighToLow: " + obj[0].sell.highToLow);

      Console.ReadLine();








      share|improve this answer













      What they said:



      • Static members are usually for helpers or factory methods, or constants

      • The API is returning an array (or List)

      • That string-foo replacement is just sketchy at best. Any time you are working with a standard like JSON or XML, use the libraries to convert it to an object, then manipulate

      Here's a working snippet:



      using System;
      using System.Net;
      using System.IO;
      using Newtonsoft.Json.Linq;
      using System.Collections.Generic;

      namespace HttpsApiTest

      class Program


      public class ForQuery

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Buy

      public ForQuery forQuery get; set;
      public long volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class ForQuery2

      public bool bid get; set;
      public List<int> types get; set;
      public List<object> regions get; set;
      public List<object> systems get; set;
      public int hours get; set;
      public int minq get; set;


      public class Sell

      public ForQuery2 forQuery get; set;
      public int volume get; set;
      public double wavg get; set;
      public double avg get; set;
      public double variance get; set;
      public double stdDev get; set;
      public double median get; set;
      public double fivePercent get; set;
      public double max get; set;
      public double min get; set;
      public bool highToLow get; set;
      public long generated get; set;


      public class RootObject

      public Buy buy get; set;
      public Sell sell get; set;


      static void Main(string[] args)

      string sURL = "https://api.evemarketer.com/ec/marketstat/json?typeid=1230&regionlimit=10000002";
      StreamReader objReader = new StreamReader(WebRequest.Create(sURL).GetResponse().GetResponseStream());
      string sLine = objReader.ReadLine();

      var obj = JToken.Parse(sLine).ToObject<List<RootObject>>();

      Console.WriteLine("Buy node:");

      Console.WriteLine(" Max: " + obj[0].buy.max);
      Console.WriteLine(" HighToLow: " + obj[0].buy.highToLow);

      Console.WriteLine("Sell node:");

      Console.WriteLine(" Max: " + obj[0].sell.max);
      Console.WriteLine(" HighToLow: " + obj[0].sell.highToLow);

      Console.ReadLine();









      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 7 at 7:05









      Sean AitkenSean Aitken

      8901018




      8901018












      • This worked perfectly! Thank you!

        – Parker Allen
        Mar 7 at 17:32

















      • This worked perfectly! Thank you!

        – Parker Allen
        Mar 7 at 17:32
















      This worked perfectly! Thank you!

      – Parker Allen
      Mar 7 at 17:32





      This worked perfectly! Thank you!

      – Parker Allen
      Mar 7 at 17:32













      0














      The string replace is going to remove all instances of square brackets. You'd be better off deserializing the response as a list of RootObjects.






      share|improve this answer



























        0














        The string replace is going to remove all instances of square brackets. You'd be better off deserializing the response as a list of RootObjects.






        share|improve this answer

























          0












          0








          0







          The string replace is going to remove all instances of square brackets. You'd be better off deserializing the response as a list of RootObjects.






          share|improve this answer













          The string replace is going to remove all instances of square brackets. You'd be better off deserializing the response as a list of RootObjects.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 5:01









          ScottyD0ntScottyD0nt

          1264




          1264





















              0














              class Data

              public string DataPoint;


              class CustomData

              public Data Dp;


              class Utility

              public T JsonDeserialisation<T>(string jsonFile)

              TextReader textReader = new StreamReader(jsonFile);
              JsonTextReader jsonReader = new JsonTextReader(textReader);
              return JsonSerializer.CreateDefault().Deserialize<T>(jsonReader);




              Since you have all classes beforehand, you can the following code generic json deserializer. Here 'T' is CustomData class






              share|improve this answer



























                0














                class Data

                public string DataPoint;


                class CustomData

                public Data Dp;


                class Utility

                public T JsonDeserialisation<T>(string jsonFile)

                TextReader textReader = new StreamReader(jsonFile);
                JsonTextReader jsonReader = new JsonTextReader(textReader);
                return JsonSerializer.CreateDefault().Deserialize<T>(jsonReader);




                Since you have all classes beforehand, you can the following code generic json deserializer. Here 'T' is CustomData class






                share|improve this answer

























                  0












                  0








                  0







                  class Data

                  public string DataPoint;


                  class CustomData

                  public Data Dp;


                  class Utility

                  public T JsonDeserialisation<T>(string jsonFile)

                  TextReader textReader = new StreamReader(jsonFile);
                  JsonTextReader jsonReader = new JsonTextReader(textReader);
                  return JsonSerializer.CreateDefault().Deserialize<T>(jsonReader);




                  Since you have all classes beforehand, you can the following code generic json deserializer. Here 'T' is CustomData class






                  share|improve this answer













                  class Data

                  public string DataPoint;


                  class CustomData

                  public Data Dp;


                  class Utility

                  public T JsonDeserialisation<T>(string jsonFile)

                  TextReader textReader = new StreamReader(jsonFile);
                  JsonTextReader jsonReader = new JsonTextReader(textReader);
                  return JsonSerializer.CreateDefault().Deserialize<T>(jsonReader);




                  Since you have all classes beforehand, you can the following code generic json deserializer. Here 'T' is CustomData class







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 6:12









                  neelesh bodgalneelesh bodgal

                  313




                  313



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036305%2fjson-api-values-0-or-false%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      1928 у кіно

                      Захаров Федір Захарович

                      Ель Греко