Link to home
Start Free TrialLog in
Avatar of Edward van Nijmweegen
Edward van NijmweegenFlag for Netherlands

asked on

How to create an array in a JSON query with C#

Hello all,

This request is refering to an existing request, which works great, but i have one small addition. In the above solution, there is only one option, but now i have more like:
"options": [
{
"key": "DOOR"
},
{
"key": "REFERENCE",
"input": "TEST JEROEN"
}
],

Open in new window


In the above solution one option is made with the following code:
     options = new[] { new { key = "DOOR" } },
                   

Open in new window


My question is, how can i make the orther(s). When i try this i get an error that my array is not correct. I tried something like:
   options = new object[] { 
                            new { key = "DOOR" }, 
                            new { key = "REFERENCE"}, 
                            new {input = dhlLabelRequest.orderReference.ToString() }

Open in new window


But this didn't work.

Thanks in advance.

Edward
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Edward van Nijmweegen

ASKER

Hello Saige,

Again thank you a lot. It is working as it should work.

Even with your comment at the end it does do the job.

Thanks,

Edward
Glad it worked out for you.

-saige-