Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mosquitto_sub -F "%J" can output invalid JSON #1222

Closed
benbarbour opened this issue Apr 1, 2019 · 1 comment
Closed

mosquitto_sub -F "%J" can output invalid JSON #1222

benbarbour opened this issue Apr 1, 2019 · 1 comment

Comments

@benbarbour
Copy link

benbarbour commented Apr 1, 2019

If something publishes invalid JSON, like a single "{" or double-quote character, to a given topic and then it's picked up by mosquitto_sub -t <topic> -F "%J" then that will print:

{
  "tst":1554162699,
  "topic":"foo",
  "qos":0,
  "retain":1,
  "payloadlen":2,
  "payload":{
}

which cannot be parsed.

Would it make sense for mosquitto_sub to output something like this if it can't properly format the output? Or maybe print nothing to stdout for that message and instead print to stderr?

{
  "tst":1554162699,
  "topic":"foo",
  "qos":0,
  "retain":1,
  "payloadlen":2,
  "payload": "<INVALID_JSON>"
}
@ralight
Copy link
Contributor

ralight commented Apr 11, 2019

This is a good point. The documentation states the payload must be valid json, but it should definitely handle the case where it isn't.

@ralight ralight closed this as completed in ad5c2e1 Dec 2, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants