in reply to How to pass variable in the LWP module
Build your string outside the call to ->content().
Also, let me recommend that you use a module to build your JSON string, for example JSON::XS.