Hello, I am facing the same problem as this post. I need to generate the json file containing the data entries.
I have created a new .tpl file and add the <template> section in templating.cfg. In the new .tpl, I write the json as plain text as it seems good
my .tpl for json output
<iw_pt name="Test">
{"test":{"field1": "<iw_value name='dcr.field1'/>","field2": "<iw_value name='dcr.field2'/>","field3": "<iw_value name='dcr.field3'/>",}}
</iw_pt>
But it doesn't make sense to handle complicated json object in this way. In the .tpl, can I use some json module in Perl for JSON encoding like this
use JSON;
my $hash = {
Waypoint => {
Name => "001",
Type => "User",
Altitude => "58.441",
Depth => "E77 32.647",
},
};
my $json_text = encode_json $hash;
print $json_text."\n";
I have pasted the above sample code enclosed by <iw_perl> in my .tpl but it does not work.
Any suggestion? Thanks.