简体   繁体   中英

I want to know the type of this value and how can I use it?

I'm creating a SDK for Camtasia, and I'm looking at this file with this piece of code:

"backgroundColor" : [239, 0, 191, 255]

Of course, I need to do more than this, but this is basically what I'm doing. I need to create the same thing but with c#. I cannot do this because it gives me an error:

jobject.Add("backgroundColor", [239, 0, 191, 255]);

But when I wrap the value around quotes, when I convert it to a string, the value is wrapped around double quotes like this:

"backgroundColor" : "[239, 0, 191, 255]"

But I can't have the value wrapped around double quotes because Camtasia can't read it, it needs it outside double quotes.

Can anyone help? I'll be glad to provide additional information if needed.

When you are wrapping with "" - you are passing a string. You need to pass array:

jobject.Add("backgroundColor", new int[]{ 239, 0, 191, 255 });

Use a JArray

string[] parameterNames = new string[] { "Test1", "Test2", "Test3" };

    JArray jarrayObj = new JArray();

    foreach (string parameterName in parameterNames)
    {
        jarrayObj.Add(parameterName);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM