C#JSON serialization

Posted by Bridget the Midget on Stack Overflow See other posts from Stack Overflow or by Bridget the Midget
Published on 2012-03-31T16:29:44Z Indexed on 2012/03/31 17:30 UTC
Read the original article Hit count: 392

Filed under:
|
|
|
|

I'm trying out the HighStock library for creating stock charts. To fill the chart with data, their example specifies this source. The first parameter is unixtime in milliseconds and the second parameter is the stock closing price. I don't know if this is valid json, but I would argue that the following would be a more appropriate way of writing json.

[{"Closing":63.15000,"Date":1262559600000},{"Closing":64.75000,"Date":1262646000000}, ...

I guess that I have no other option than to adapt to HighStocks syntax. I could solve this by looping and add correct syntax to a string, but that seems rudimentary. Would it be more wise to serialize C# objects to create my json, and if that's the case - how can I reach the syntax specified in the example?

Lets just say this is my c# object:

public class Quote {
  public double Date { get; set; }
  public decimal Closing { get; set; }
}

Am I making it unnecessary complex? Should I just format a json string?

© Stack Overflow or respective owner

Related posts about c#

Related posts about JSON