Home > Net >  REST - HTTP POST call JSON content parse error
REST - HTTP POST call JSON content parse error

Time:09-22

I am using https://reqbin.com/ to make a POST call and below is my JSON content. I am getting parse error on line 1 near [. JSON is supposed to start with [ or {. Please can you let me know how to fix this? Thanks

[
    'create' => 'true',
    'line2' => 'USD',    
    'line3' => '1100',
    'line4 => ['1','2']

]

CodePudding user response:

It depends on what the json should be. If it is a single object you have to use {} Keys and String values in double quotes, numbers and boolean values without quotes. The separator for key and value is :

  {"create" : true,
    "line2" : "USD",    
    "line3" : 1100,
    "line4" : [1,2]}

if it should be an array, it must surrounded by [] and there must be objetcs in it

CodePudding user response:

If you want an array with a single item, you might mean:

[
    {
        "create": "true",
        "line2": "USD",    
        "line3": "1100",
        "line4: [ 
            {"1": "some-value"},{"2": "some-value"}
        ]
    }
]

If you just want the single object, remove the [ ] denoting the outer array

  • Related