1

I have a section on my server that looks like this:

private static dynamic Data;
string ArraySize = "[900,900,2]";
Data = new { c2array = true, size = ArraySize };
System.IO.File.WriteAllText("json.txt", JsonConvert.SerializeObject(Data));

which spits this out:

{"c2array":true,"size":"[900,900,2]"}

yet in JavaScript I can get it to this with json.stringify:

{"c2array":true,"size":[900,900,2]} <--- no quotes

how can i get the c# JSON serialize to not wrap quotes around the string.

I'm using a string value because if I try the following

Data = new { c2array = true, size = [900,900,2] };

it won't compile

the client script I'm sending this to is a game programming library in JavaScript and it expects the size without quotes.

1 Answer 1

2

Don't make ArraySize a string.

var ArraySize = new int[] {900,900,2};
Data = new { c2array = true, size = ArraySize };
Sign up to request clarification or add additional context in comments.

1 Comment

thankyou worked like a charm says I can't accept an answer for 7 minutes but will when it lets me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.