diff --git a/Anvil/Tools/Words.pm b/Anvil/Tools/Words.pm
index 457c1f93..b674ae13 100755
--- a/Anvil/Tools/Words.pm
+++ b/Anvil/Tools/Words.pm
@@ -8,6 +8,7 @@ use warnings;
use Data::Dumper;
use XML::Simple qw(:strict);
use Scalar::Util qw(weaken isweak);
+use JSON;
our $VERSION = "3.0.0";
my $THIS_FILE = "Words.pm";
@@ -255,10 +256,6 @@ Parameters;
This is the double-banged string to process. It can take and process multiple lines at once, so long as each line is in the above format, broken by a simple new line (C<< \n >>).
-=head3 json_escape (optional, default '0')
-
-If set to C<< 1 >>, and double-quote (C<< " >>) characters will be escaped (ie: for use in JSON files).
-
=cut
sub parse_banged_string
{
@@ -268,13 +265,9 @@ sub parse_banged_string
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
# Setup default values
- my $out_string = "";
- my $key_string = defined $parameter->{key_string} ? $parameter->{key_string} : 0;
- my $json_escape = defined $parameter->{json_escape} ? $parameter->{json_escape} : 0;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
- json_escape => $json_escape,
- key_string => $key_string,
- }});
+ my $out_string = "";
+ my $key_string = defined $parameter->{key_string} ? $parameter->{key_string} : 0;
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { key_string => $key_string }});
# There might be multiple keys, split by newlines.
foreach my $message (split/\n/, $key_string)
@@ -337,15 +330,6 @@ sub parse_banged_string
}
}
- if ($json_escape)
- {
- # Escape characters needed for use in json.
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ">> out_string" => $out_string }});
- $out_string =~ s/\"/\\\"/msg;
- $out_string =~ s/\n/
/msg;
- $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "<< out_string" => $out_string }});
- }
-
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { out_string => $out_string }});
return($out_string);
}
diff --git a/share/words.xml b/share/words.xml
index 5dc6bea7..8faf7059 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -470,11 +470,7 @@ Here we will inject 't_0006', which injects 't_0001' which has a variable: [#!st
Configure Network
The network configuration will be updated based on the variables stored in the database. Reconnecting to the machine using the new IP address may be required.
Update Striker
-
-This "system" is now scheduled to be updated.
-Here's a "multi" quoted "multi" line.
-OK, go!
-
+ This system is now scheduled to be updated.
The IP address will change. You will need to reconnect after applying these changes.
diff --git a/tools/anvil-daemon b/tools/anvil-daemon
index 5fefb8e1..7190aeeb 100755
--- a/tools/anvil-daemon
+++ b/tools/anvil-daemon
@@ -16,6 +16,7 @@ use strict;
use warnings;
use Anvil::Tools;
use Proc::Simple;
+use JSON;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@@ -54,10 +55,6 @@ if (not $anvil->data->{sys}{database}{connections})
}
}
-my $say_description = $anvil->Words->parse_banged_string({json_escape => 1, key_string => "job_0004"});
-print "say_description: [".$say_description."]\n";
-die;
-
# Read switches
$anvil->data->{switches}{'run-once'} = "";
$anvil->data->{switches}{'main-loop-only'} = "";
@@ -282,9 +279,9 @@ sub run_jobs
}});
# Convert the double-banged strings into a proper message.
- my $say_title = $job_title ? $anvil->Words->parse_banged_string({debug => 2, json_escape => 1, key_string => $job_title}) : "";
- my $say_description = $job_description ? $anvil->Words->parse_banged_string({debug => 2, json_escape => 1, key_string => $job_description}) : "";
- my $say_status = $job_progress ? $anvil->Words->parse_banged_string({debug => 2, json_escape => 1, key_string => $job_status}) : "";
+ my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
+ my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
+ my $say_status = $job_progress ? $anvil->Words->parse_banged_string({key_string => $job_status}) : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
job_title => $job_title,
say_description => $say_description,
@@ -292,18 +289,22 @@ sub run_jobs
}});
# Add this to the jobs.json file
- $jobs_file .= "{ \"job_uuid\":\"".$job_uuid."\",
- \"job_command\":\"".$job_command."\",
- \"job_data\":\"".$job_data."\",
- \"job_picked_up_at\":\"".$job_picked_up_at."\",
- \"job_updated\":\"".$job_updated."\",
- \"job_name\":\"".$job_name."\",
- \"job_progress\":\"".$job_progress."\",
- \"job_title\":\"".$say_title."\",
- \"job_description\":\"".$say_description."\",
- \"job_status\":\"".$say_status."\",
- \"started_seconds_ago\":\"".$started_seconds_ago."\",
- \"updated_seconds_ago\":\"".$updated_seconds_ago."\" }, \n";
+ my $json_string = to_json ({
+ job_uuid => $job_uuid,
+ job_command => $job_command,
+ job_data => $job_data,
+ job_picked_up_at => $job_picked_up_at,
+ job_updated => $job_updated,
+ job_name => $job_name,
+ job_progress => $job_progress,
+ job_title => $say_title,
+ job_description => $say_description,
+ job_status => $say_status,
+ started_seconds_ago => $started_seconds_ago,
+ updated_seconds_ago => $updated_seconds_ago,
+ });
+ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { json_string => $json_string }});
+ $jobs_file .= $json_string."\n";
# If the job is done, move on.
next if $job_progress eq "100";