algorithmic modeling for Rhino
Hi,
Is it possible to write such a link to json object?
"http:\/\/127.0.0.1:8000\/?"
I am using json.net and I want to pass a string to json.
It is not possible to use such symbols in strings and only other option I found was to use @ before string:
var a = new JProperty("b", @"http:\/\/127.0.0.1:8000\/?" );
However this is not good for me because when I write this property to json file I get this:
"b": "http:\\/\\/127.0.0.1:8000\\/?"
I want to have one "\" instead of two "\\".
It is not necessary to pass string to jproperty, I can pass other object type too.
Therefore, the questions sums up:
How the type name in C# is called to pass such url?
Tags:
If you put an @ symbol before the string, then what you type is what you get. Those additional strokes must somehow be inserted after the fact. It's probably because those characters mean something specific in JSON and must therefore be 'escaped'.
http://stackoverflow.com/questions/1242118/how-to-escape-json-string
I had no such troubles, afaik. json.net (newtonsoft) usually just takes care of that for you. It's easy to use anon objects. And also dangerous in the long run :)
var x = new { a = @"https://speckle.works", b = "shamelessplug", c = 12 };
var myString = JsonConvert.SerialzeObject(x);
Imma not sure why all the escaping in the original string. If a url just needs to stay that way, type it normally and put in the @ before the "".
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by