Closed leonsi7 closed 9 months ago
Hi, did you try facet raw:true in the connect statement? It was the same case for other protocol and need to be Raw. 2nd, try operator to_json to get the correct json formatted string , i think.
Hi, for the first thing : My code has
do connect to: "localhost" port: 1883 login:"admin" password:"admin" with_name: "sender" raw:true;
And then :
do send to:"receiver" contents: as_json_string(message_location);
Where we have
map<string,map> message_location;
And I receive the something like the XML above. The facet raw is designed only for TCP and Websocket as mentionned here
For the second part, I actually used the function as_json_string(message_location)
as mentionned above.
now mqtt servers should take into account the raw facet, can you test if it fits your needs @leonsi7 ?
I consider that it works now, if you see any problem with that implementation feel free to reopen @leonsi7
Is your request related to a problem? Please describe.
First problem I'm working on using MQTT to couple GAMA model with other models. When I use
do connect
anddo send
in order to create a MQTT message, the problem is that if I send a content such as a string, it creates automatically a xlm to enclose the message. For example : If I send the messagetest
, I would get:Here tou can see that
test
is sourrounded by a lot of unuseful information.Second problem A second problem appears when I use stringified JSON. For instance, let's consider the following map:
map(["x"::10,"y"::20])
, the sent essage (without the sourrounded xml) is{&quot;x&quot;:10,&quot;y&quot;:20}}
, which is not expected because I expect{"x":10,"y":20}
for my JSON parser.Describe the improvement you'd like I would like to add a new parameter for the send function, something like
send_raw:True
which would send the raw message without the xml and using character such that"
and not"
.Describe alternatives you've considered The only current alternative is to use the second model or and api to denoise the mqtt message (removing xml and replacing useful character for JSON by the right one).
Additional context None