This might be really simple, but I am having trouble getting it. I am trying to create a template for a message that will contain a variable length string. The string is usually 2062 characters long, so if I do this:
JAddStringToObject(body, “log_data”, “2062”);
does it mean I am allocating a fixed length string, or is the string variable length?
The string will be either empty or “none”, 150 bytes or 2062 bytes. Maybe I could create three templates with different data lengths.
This is different on versions prior to v3.2.1 and after. In the older versions, the length is the max length a string can be, but a string of any length up to that can be used. In the later versions, the string is variable length. I am however not sure of the specifics of this, as the documentation is unclear, I will follow up.
Just to clarify - when you are establishing a template (which only needs to be done once), the value you pass to configure a given parameter as a string can be any arbitrary string value. Like Kimball stated, as long as you are on Notecard firmware >= 3.2.1, you don’t have to specify a length argument either, and thus strings can be of any length:
JAddStringToObject(body, "log_data", "x");
When using this template, your log_data string can be any length.
If you need to route three different sets of data, having three different Notefile names (and thus three different templates) is probably the right way to go.