Passing a JSON Object as a parameter

Aug 3, 2012 at 8:55 AM

Hello,

Does Javascript.Net support the use of JSON objects as parameters.

I am Adding the parameter as shown below:

context.SetParameter("JSONObj", json);

And my script is trying to access the JSONobj by:

var x = JSONObj.IntPoints;

This does not seem to be working.

Any help or information would be greatly appreciated.

Thanks in advance

Dar13s

Below is the JSON Object I am trying to pass.

{"Client":{"AddressLine1":"Address 1","AddressLine2":"Address 2","County":"County","PostCode":"PostCode","Town":"Town","Name":"ClientName"},"DoublePoints":1.23,"Installation":{"AddressLine1":"InstallAddress 1","AddressLine2":"InstallAddress 2","County":"InstallCounty","PostCode":"InstallPostCode","Town":"InstallTown","Name":"InstallName"},"IntPoints":123,"Report":"This is a string value"}

Developer
Aug 5, 2012 at 11:47 PM

So you passed in a string and now you are surprised that it is still a string, rather than an object?  Consider using JSON.parse().

Aug 6, 2012 at 9:34 AM

Brilliant thanks for your reply.

JSON.parse() seems to work.

Sep 24, 2013 at 1:53 AM
Edited Sep 24, 2013 at 1:53 AM
I don't get it, how do you use JSON.parse() ?

Like this?

string output = HandleBars.Run("Tiraggo", "JSON.parse(" + json + ")");

It doesn't work, I'm totally lost, how could there not be a sample of passing in JSON? Seems like one of the whole points of the library, can anybody help here?
  • Mike
Sep 24, 2013 at 2:03 AM
Uggh !! Here's how folks ...

string json = "JSON.parse(" + myjson+ ")";
string output = HandleBars.Run("Tiraggo", json);