せっけんを使ったWebサービスの作成に取り組んでいます。私はperlを使用してハッシュをJSONに変換する方法を見つけようとして立ち往生しています。現在、クライアント側でテストしており、JSONを印刷しようとしています。そのため、問題がサーバー側にあるのかクライアント側にあるのかわかりません。
これが私のサーバー側のコードです。
#create hash
my %hash_to_encode = (
weigh => $weight,
price => $price,
unit => $unit,
picture=> $picture,
amount => $amount,
dimensions => $dimensions,
country => $country,
description => $description,
name => $name,
category => $category,
comment => $comment,
expires => $expires
);
my $json_string = JSON->new->utf8->encode(%hash_to_encode);
return $json_string;
My client side code:
#! /usr/bin/perl -w
use CGI qw(:standard);
use SOAP::Lite;
use JSON;
print "Content-type: text/html\n\n";
my $exhibitID = '13';
my $username = 'us43';
my $password = 'green4356';
my $link = 'its a secret :P';
my $namespace = 'also a sewcret';
#The soap call works (i have other functions and they work as expected so dont worry about this part.
my $mySoap = SOAP::Lite
-> uri($link)
-> proxy($namespace);
#This is where the error lies.
my $result = $mySoap->status($exhibitID, $username, $password)->result;
print "Json String: $result";
#my $jsonString= JSON->new->utf8->decode($result);
#print "Status is: $jsonString";
print "<p> Finished status</p>";
助けてくれてありがとう :)