mdhiggins / ESP8266-HTTP-IR-Blaster

ESP8266 Compatible IR Blaster that accepts HTTP commands for use with services like Amazon Echo
MIT License
968 stars 217 forks source link

json parsing fail #309

Closed SdeGeata closed 3 years ago

SdeGeata commented 3 years ago

Hello!

So i finally got around to starting work on this, but am having troubles with the json stuff.

If i use the code as is from your example, "Json as URL", it goes fine - of course i have nothing that responds to those codes. Here's the thing, once I plug my own codes in, I get parsing errors. 1FEB04F doesn't work if I send with json, but if I send it according to the "Basic Output" format, it sends fine. I have tried prefixing it with 0x, that makes no difference.

Any ideas?

SdeGeata commented 3 years ago

A small update:

Further testing reveals to me that it is not my code throwing the error. It seems to be that it doesn't like me swapping repeat for pulse. Any idea why???

mdhiggins commented 3 years ago

JSON parsing error means you're formatting your JSON object incorrectly

If you post what you're trying I can take a look but check your syntax

SdeGeata commented 3 years ago

Hey! Thanks for your prompt reply!

So this is what I'm playing with right now. Its a two button sequence; the first turns the unit on, the second adjusts temperature.

http://ArizerIRDblaster.local:80/json?pass=PASSWORD&plain=[{"type":"nec","data”:”1FE7887”,”length":32,”address”:0x80},{“type":"nec","data”:”1FEB04F”,”length":32,”address”:0x80,”pulse”:10,”pdelay”:100}]

Still getting errors.

mdhiggins commented 3 years ago

Couple things

http://ArizerIRDblaster.local:80/json?plain=[{type:"nec",data:"1FE7887",length:32,address:"0x80"},{type:"nec",data:"1FEB04F",length:32,address:"0x80",pulse:10,pdelay:100}]&pass=PASSWORD
SdeGeata commented 3 years ago

You don't have to use quotes around the key for ArduinoJson if you want to make your URLs shorter

Ah, well that is good to know. I took the example off of the page but it seemed quotation mark heavy.

You forgot quotes around the address which are required (simple integers don't need this but anything else does)

Also good to know.

Whatever character you're using for quotes in some places isn't a normal quote, I would use a proper programming text editor cause " is different than ” which will parse differently

Yeah, i discovered that my computer was automatically changing the straight brackets and replacing them with curly ones. A programming app doesn't seem to make a difference - I use Nova. I did find the option to turn it off in my settings though so all is well.

Thank you for your help and good work.