Note that there are some explanatory texts on larger screens.

plurals
  1. POjson result is being returned wrapped in double quotes
    primarykey
    data
    text
    <p>I am trying to return a json string via jQuery of an object using the following function. The problem I do not seem to be able to overcome is my json result comes out the other end wrapped in double quotes.</p> <p>I have seen in <a href="https://stackoverflow.com/questions/2998455/asp-net-webmethod-returns-json-wrapped-in-quotes">this</a> post that I should;</p> <blockquote> <p>have your method return an actual object and let the JSON serialization of the framework do the heavy lifting for you</p> </blockquote> <p>But I don't fully understand that this means.</p> <p>This is the function I am using.</p> <pre><code>Public Function getLine() As String Dim data As List(Of ArrayList) = New List(Of ArrayList) For Each q In getAllData() Dim a As New ArrayList Dim d As Date = q.DateTime a.Add(d.Ticks) a.Add(q.TotalRevenue) data.Add(a) Next Dim s As New Serie s.data = data Dim str As String = JsonConvert.SerializeObject(s) Return str End Function </code></pre> <p>Any ideas greatly appreciated.</p> <pre><code>$.ajax({ type: "POST", dataType: "json", data: "{}", contentType: "application/json; charset=utf-8", url: "_services/ScriptService.asmx/getData", success: function (items) { var data = eval("(" + items.d + ")"); }, cache: false, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); } }); </code></pre> <p>'items.d' contains...</p> <pre><code>"{"data":[[634420512000000000,100000.0000] ... [634421376000000000,100086.0000]]}" </code></pre> <p>if i eval 'items.d' i get...</p> <pre><code>[[634420512000000000, 100000] ... [634421376000000000, 100086] </code></pre> <p>I read somewhere that eval is evil, is this true?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload