in reply to Re^2: JSON parsing issue please help
in thread JSON parsing issue please help
No, you're not getting the output you show using the JSON you posted. Look at the #@%!^ JSON you posted. It is not capable of resulting in the output you are showing. Here's what I get when I test it:
use strict; use warnings; use File::Slurp; use JSON; my $json = read_file(\*DATA); my $j = JSON->new; my %json_text = %{ $j->decode($json) }; while( my ( $key, $value ) = each %json_text ) { print "$key = $value\n"; } __DATA__ { "alertCounts" : [ { "count" : 5, "rule" : "rule1" }, { "count" : 16, "rule" : "rule2" } ], "balArray" : [ { "containerArray" : [], "name" : "user_ip" }, { "containerArray" : [ { "entryArray" : [ { "action" : "flag", "expires" : "00:00:00", "hitsSinceAdded" : 56, "name" : "/my/page", "priority" : 4, "rule" : "rule1", "timestamp" : "15:28:40.150" } ], "name" : "192.168.1.100" }, { "entryArray" : [ { "action" : "flag", "expires" : "00:00:00", "hitsSinceAdded" : 185, "name" : "/my/page", "priority" : 4, "rule" : "rule2", "timestamp" : "15:12:55.961" } ], "name" : "192.168.1.101" }
And the output:
, or ] expected while parsing array, at character offset 1206 (before +"(end of string)") at ./mytest.pl line 12.
I don't know how many more times you need someone to tell you that the sample input you're posting isn't capable of producing any reasonable output because it's broken. Post real JSON that isn't malformed, and we can begin to talk about your code.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: JSON parsing issue please help
by diamondsandperls (Beadle) on Sep 29, 2012 at 20:51 UTC | |
by james2vegas (Chaplain) on Oct 01, 2012 at 10:00 UTC | |
by Anonymous Monk on Sep 30, 2012 at 06:26 UTC | |
by Anonymous Monk on Sep 30, 2012 at 06:24 UTC |