in reply to Re: Json epoch datetime with perl
in thread Json epoch datetime with perl

I want to pass this JSON object to a Web Service and the example structure given for the object is showing the similar kind of backslashes. Here is the exact copy paste of that field. Date is in epoch milliseconds.
"RoundStartTime":"\/Date(1400569278222)\/",

Replies are listed 'Best First'.
Re^3: Json epoch datetime with perl
by poj (Abbot) on May 28, 2014 at 10:07 UTC
    Try
    #!perl; use strict; use JSON; my $json = new JSON->escape_slash(); my $roundParams = { 'AllowParticipantsToSeeEachOther' => JSON::PP::true, 'DurationInMinutes' => 10, 'MaxGamePegValue' => 5, 'MaxNumberOfCrackAttemptsPerCode' => 18, 'MaxNumberOfCrackAttemptsPerTeam' => 0, 'NumberOfDefaultHostParticipants' => 1, 'NumberOfPegsInRound' => 4, 'RoundStartTime' => "/Date(".time.")/", 'TimeBetweenRoundATimeBetweenRoundAttemptsInSeconds' => 10 }; print $json->encode($roundParams);
    poj
      Thanks a lot man. This worked out perfectly. Surprised, I still couldn't find such a thing over google or in docs.