perl JSON到XML的转换

时间:2017-07-22 21:14:05

标签: json xml perl

你好我在使用JSON中的perl API调用并将其转换为XML时出现问题,我只是这样做,因为原始应用程序调用JSON对象只是我不断获取 “格式错误的JSON字符串,无论是数组,对象,数字,字符串还是原子,在help.pl第22行的字符偏移0(在字符串结尾处)之前”。

出于安全原因,我遗漏了我的API密钥......

#!/usr/bin/env perl 

use strict;
use warnings;
use JSON qw( decode_json );
use LWP::Simple;


# Creates an UserAgent object.
my $ua = LWP::UserAgent->new( );
# Enable in-memory cookie management
$ua->cookie_jar( {} );
# Disable verify host certificate (only needed for self-signed cert)
$ua->ssl_opts( 'verify_hostname' => 0 );
# Sends a request that does the authorization to grant a session.
# Because we enabled cookie management, it will get stored
my $response = $ua->get(
'https://rimon.namely.com/api/v1/profiles.json',
'content-type' => 'application/json; charset=utf-8',
'Authorization' => "Bearer "
);
print decode_json($response)->{'R328'}->{'MKQQ2B/A'};

0 个答案:

没有答案