Reputation:
I need to identify what JSON
values my server expects. I've been doing testing within Haskell, and all is well. So now I need to take the next step so I can document what these values look like for other people to use.
One of my REST
methods expects an Array
Array (fromList [String "BNAP",Number 312])
is how Haskell expresses this.
Testing with cURL
, I want to do something like this:
curl -D- -X POST -H "Content-Type: application/json" --data '["BNAP":312]'
http://10.64.16.6:3000/Read
But this seems to not be valid JSON
ParseError {errorContexts = ["]"], errorMessage = "Failed reading: satisfyWith", errorPosition = 1:8}
If Haskell was expecting an Object Object (fromList [String "BNAP",Number 312])
for example, the JSON would be expressed this way
--data '{"BNAP":312}'
So to me, it follows that my above attempt would be right. But, it's not. So, how does one express an Array with one Pair consisting of a String and a Number, with cURL?
Upvotes: 0
Views: 1907
Reputation: 139890
The colon is not valid JSON here:
["BNAP":312]
^
Array elements should be separated by a comma:
["BNAP", 312]
If you wanted an array with a single key-value pair, you need to add curly braces:
[{"BNAP": 312}]
Upvotes: 4