jlb333333 has asked for the wisdom of the Perl Monks concerning the following question:
Hi.
I am trying to modify the input data structure of json data.
Current structure:
{"OWNER":"KeyProjects","Region":"Southern","District":"Arid","PLANTNO" +:"Sunset View","COMPT":"A08","age1":null,"ht1":null,"age2":null,"ht2" +:null,"age3":null,"ht3":null,"age4":null,"ht4":null,"age5":null,"ht5" +:null,"age6":null,"ht6":null,"age1":null,"ht1":null,"age2":null,"ht2" +:null,"age3":null,"ht3":null,"age4":null,"ht4":null,"age5":null,"ht5" +:null,"age6":null,"ht6":null,"wc":"EF1"},
I want it to look like this:
{"OWNER":"KeyProjects","Region":"Southern","District":"Arid","PLANTNO" +:"Sunset View","COMPT":"A08","scheduled":{"age1":null,"ht1":null,"age +2":null,"ht2":null,"age3":null,"ht3":null,"age4":null,"ht4":null,"age +5":null,"ht5":null,"age6":null,"ht6":null},"completed":{"age1":null," +ht1":null,"age2":null,"ht2":null,"age3":null,"ht3":null,"age4":null," +ht4":null,"age5":null,"ht5":null,"age6":null,"ht6":null},"wc":"EF1"}
(two sections are now nested(extra{}s), with the words "scheduled" and "completed" added).
The fields of the original data vary in length so simply counting characters to find an insert point will not help.
Just can't get perl regex to do what I want it to do.
Assistance would be greatly appreciated
John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find a Position and Insert Text
by Your Mother (Archbishop) on Mar 15, 2016 at 18:05 UTC | |
by jlb333333 (Novice) on Mar 16, 2016 at 18:32 UTC | |
by Your Mother (Archbishop) on Mar 16, 2016 at 20:44 UTC | |
by Corion (Patriarch) on Mar 17, 2016 at 07:49 UTC | |
by Your Mother (Archbishop) on Mar 17, 2016 at 17:28 UTC | |
by jlb333333 (Novice) on Mar 19, 2016 at 11:24 UTC | |
by Your Mother (Archbishop) on Mar 20, 2016 at 19:20 UTC | |
| |
|
Re: Find a Position and Insert Text
by Corion (Patriarch) on Mar 15, 2016 at 17:53 UTC | |
by jlb333333 (Novice) on Mar 16, 2016 at 18:35 UTC | |
|
Re: Find a Position and Insert Text
by toolic (Bishop) on Mar 15, 2016 at 17:51 UTC |