Subject: | SYNOPSYS example code failed to run. |
Date: | Fri, 2 Jan 2015 14:27:20 -0800 |
To: | "bug-JSON-Path [...] rt.cpan.org" <bug-JSON-Path [...] rt.cpan.org> |
From: | Tom Rutledge <tom.rutledge [...] bigfishgames.com> |
http://search.cpan.org/~tobyink/JSON-Path-0.205/lib/JSON/Path.pm
References some example code that does not run for two reasons.
1. A syntax error in the data structure.
2. Use of an initialized object $object. (with a strange error message)
I was able to get everything happy with :
bash-3.2$ diff synopsis_example synopsis_example.fixed.2
2a3
Show quoted text
> use JSON::Path;
31,32c32,33
< { "color": "red",
< "price": 19.95,
---
Show quoted text> { "color"=> "red",
> "price"=> 19.95,
48c49
< jpath_map { uc $_ } $object, '$.store.book[*].author';
---
Show quoted text> jpath_map { uc $_ } $data, '$.store.book[*].author';
bash-3.2$
Example : failure log
bash-3.2$ perl --version
This is perl 5, version 16, subversion 3 (v5.16.3) built for darwin-thread-multi-2level
Copyright 1987-2012, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
First issue :
bash-3.2$ ./synopsis_example
syntax error at ./synopsis_example line 31, near ""color":"
BEGIN not safe after errors--compilation aborted at ./synopsis_example line 47.
bash-3.2$
Second issue :
bash-3.2$ ./synopsis_example.fixed.1
malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /Users/tom.rutledge/perl5/lib/perl5//JSON/Path.pm line 57.
bash-3.2$
Fixed version :
bash-3.2$ ./synopsis_example.fixed.2
bash-3.2$
Thank you for your time.
Tom Rutledge
Big Fish Games, Inc. A New Game Every Day! (r)<http://www.bigfishgames.com> <http://www.bigfishgames.com>