title: How to view and or read contents of a JSON object in C#?
body: <p>I am working on a project that uses data to generate a "Highcharts" plot. Basically, its just an x/y lineseries plot, but the chart is using the wrong data for the x-axis. I am trying to figure out why this is occuring. The snippet of code that I have is as follows:</p>
  
  <pre><code>var data = this.costAnalyzerService.OpenCostWindow(DataToSend, CurrentTrain, CustId);
  var obj = Json(data, JsonRequestBehavior.AllowGet);
  return obj;
  </code></pre>
  
  <p>The "data" variable is of type <code>Systems.Collections.Generic.List&lt;System.Tuple&lt;int, double, double&gt;&gt;</code></p>
  
  <p>Basically, all the data in this variable is correct. The int should be my x-axis, and the two doubles are my two sets of line series data. I have reason to believe that the code that is generating the plot is not using the "int" as the x-axis. Rather, it is simply using 1,2,3...,N points as the x-axis numbers. </p>
  
  <p>How can I peek into this "JSON" object to see what is going on and what it is returning. If I step through the code past this point, the chart simply generates and the execution of the application finishes. There are no more step points to debug after this point. Literally, the function returns the JSON object and finishes. It doesn't even return to the calling function, so far as I can tell. </p>
  
  <p>Here is the COMPLETE method that I am working with:</p>
  
  <pre><code> public JsonResult PlotCostAnalyzerChart(double acidPrice = 0.0, double causticPrice = 0.0, int acidUsage = 0, int causticUsage = 0, int cationResin = 0, int anionResin = 0, bool loadOnSettingsUpdate = false)
      {
          try
          {
              PriceData DataToSend = this.Session["Data_ToSend"] != null ? Session["Data_ToSend"] as PriceData : new PriceData();
              string CustId = this.Session["CustomerId"] != null ? Session["CustomerId"].ToString() : string.Empty;
  
              if (loadOnSettingsUpdate)
              {
                  DataToSend.AcidPrice = acidPrice;
                  DataToSend.CausticPrice = causticPrice;
                  DataToSend.AcidUsage = acidUsage;
                  DataToSend.CausticUsage = causticUsage;
                  DataToSend.AmountCation = cationResin;
                  DataToSend.AmountAnion = anionResin;
              }
              else
              {
                  DataToSend.AcidUsage = 6;
                  DataToSend.CausticUsage = 6;
                  DataToSend.AmountCation = 600;
                  DataToSend.AmountAnion = 600;
              }
  
              int CurrentTrain = 1;//set the current train in scope
              //if (Session["SelectedTrain"]!=null)
              //{
              //    CurrentTrain = int.Parse(Session["SelectedTrain"].ToString());
              //}
              var data = this.costAnalyzerService.OpenCostWindow(DataToSend, CurrentTrain, CustId);
              var obj = Json(data, JsonRequestBehavior.AllowGet);
              return obj;
          }
          catch
          {
              throw;
          }
      }
  </code></pre>
  
  <p>Input, advice, and suggestions are greatly appreciated! </p>
  
  <p>Here is some java-script that I believe is generating the plot:</p>
  
  <pre><code>$(function () {
  $.ajax({
      url: 'PlotCostAnalyzerChart',
      type: "GET",
      dataType: "json",
      success: function (jsonData) {
          $.ajax({
              url: 'GetCumulativeSavings',
              type: 'GET',
              success: function (CumulativeSavingsData) {
                  $("#CumulativeSavings").empty();
                  $("#CumulativeSavings").html(CumulativeSavingsData);
              },
              error: function (xhr) {
                  window.location.href = "/ClientDatabase/Errorview";
              }
          });
          var arrxaxis = new Array();
          var arrWithOutClean = new Array();
          var arrWithClean = new Array();
          for (var i = 0 ; i &lt; jsonData.length ; i++) {
              var mxaxis = new Object();
              var mWithOutClean = new Object();
              var mWithClean = new Object();
              mxaxis = jsonData[i];
              mWithOutClean = jsonData[i];
              mWithClean = jsonData[i];
              arrxaxis.push(mxaxis.Item1);
              arrWithOutClean.push(mWithOutClean.Item2);
              arrWithClean.push(mWithClean.Item3);
          }
          //alert(arr);
          $('#graph_CostAnalyzer').empty();
          $('#graph_CostAnalyzer').highcharts({
              chart: {
                  zoomType: 'x'
              },
              title: {
                  text: 'Cost Analyzer',
                  x: -20 //center
              },
              xAxis: {
                  title: {
                      text: 'Number of Weeks'
                  }
              },
              yAxis: {
                  title: {
                      text: 'Cost of Operations'
                  }
              },
              credits: {
                  enabled: false
              },
              tooltip: {
                  crosshairs: true,
                  formatter: function () {
                      return 'Week Number : ' + this.point.x + '&lt;br&gt;' + this.series.name + ' : ' + Highcharts.numberFormat(this.point.y, 2) + '&lt;br&gt;' + 'Click on chart to get cost analysis';
                  }
  
              },
              plotOptions: {
                  series: {
                      cursor: 'pointer',
                      point: {
                          events: {
                              click: function (e) {      
                            $("#CostAnalyzerResultsTable").fadeOut(300);
                                  $.ajax({
                                      url: 'GetResultsTable',
                                      type: "GET",
                                      data: { weekNumber: this.x },
                                      success: function (CostAnalyzerResultsData) {
                                          //alert(CostAnalyzerResultsData);
                                          $("#CostAnalyzerResultsTable").empty();
                                          $("#CostAnalyzerResultsTable").html(CostAnalyzerResultsData);
                                          //FADEOUT AND FADEIN           
                                          $("#CostAnalyzerResultsTable").fadeIn(400);
                                      }
                                  });
                              }
                          }
                      },
                      marker: {
                          lineWidth: 1
                      }
                  }
              },
              legend:{
                  enabled: true,
                  layout: 'horizontal',
                  borderWidth: 1
              },                
              series: [{
                  name: 'With RTI Cleaning',
                  data: arrWithClean
              },
              {
                  name: 'Without RTI Cleaning',
                  data: arrWithOutClean
              }]
          });
      }
  });
  </code></pre>
  
  <p>});</p>