last day (14 days later) » 

12:50 PM
1
Q: Decode json in bugzilla template?

zicoHow to decode Json in Bugzilla template ? how can I load the JSON Plugin correctly? [% USE JSON ( pretty => 1 ) %]; <script type="text/javascript"> var foo = [% foo.json %]; </script> or read in JSON [% USE JSON %] [% data = JSON.json_decode(json) %] ...

 
version of Bugzilla is 5x
 
Do you have that plugin module installed?
 
I think yes , after doing ./checksetup.pl I got a list of plugins, and the JSON XS is in Checking for JSON-XS (v2.01) ok: found v3.02
 
That sounds like you have the module JSON (or JSON::XS) installed. That's not the same as your Template::Plugin::JSON. See stackoverflow.com/a/3736710/1331451 for how to install it. The easiest way will be cpan Template::Plugin::JSON or cpanm Template::Plugin::JSON on the command line of the host that's runing the Bugzilla installation.
 
Are they the same plugin JSON and JSON-XS, when I did [% USE JSON-XS %] and error with unexpected token (-) [% USE JSON-XS %]
 
12:50 PM
You have to use :: (two colons). The - minus is just used in distribution names. In code, you need the ::. There is no JSON::XS plugin for Template Toolkit. In general, the ::XS says that it's not written in Perl, but rather it uses a C library that is connected to Perl to speed things up.
I'm pretty sure you don't have that plugin installed.
 
I tried with,JSON::XS but it gave me the same " plugin error - JSON::XS: plugin not found "
 
Yeah. There is no plugin for JSON::XS. I looked on CPAN for it.
Do you know how to install a module from CPAN?
 
yes , I do , but I don't have the access from the machine to go to the internet :(
 
The answer I linked above should explain how you can do that.
I guess you're a frontend dev and you usually write Template code.
If you are comfortable enough to do that, you can also just take the module code from metacpan.org/source/NEILB/Template-Plugin-JSON-0.07/lib/… and just add it to your regular code repo.
That way you don't need to install.
But there are numerous posts on SO that explain how to install CPAN stuff without root and without internet. local::lib is your friend.
The code of that plugin is super simple.
You can probably just chck that in with your own code.
I need to go to a meeting now. Good luck :)
 

last day (14 days later) »