On the parsing problem of JSON
This post was last edited by u012884755 on 2015-04-14 10:16:22
$id = $this->input->post (' program_id ');
$related _change = Json_decode ($this->input->post (' Related_change '));
$data = Array (
' User_key ' = $related _change (' User_key '),
' channel_id ' = $related _change (' channel_id '),
' Date ' = $related _change (' Date '),
' Program ' = = Array (
' Name ' = $related _change-> (' program_name '),
' Type ' = $related _change (' Program_type '),
' Start_time ' + date (' y-m-d h:i:s ', $related _change (' Program_start_timestamp ')),
' End_time ' + date (' y-m-d h:i:s ', $related _change (' Program_end_timestamp ')),
' Duration ' = (int) $related _change (' Program_end_timestamp ')-(int) $related _change (' Program_start_timestamp '),
' Source_duration ' = Time_to_sec ($related _change (' program_original_duration ')),
' Source_type ' = (string) $related _change (' Src_type '),
' Source_start_ts ' = $related _change (' Src_start_time ')
The ' uri ' = = (string) $related _change (' Program_uri '),
)
);
This piece of data is wrong to parse.
They're not from the $thi->input->post, but from the $related _change.
How do you write it?
------to solve the idea----------------------
$related _change = Json_decode ($this->input->post (' Related_change '), true);
$data = Array (
' user_key ' + $related _change[' User_key '),
' channel_id ' = $related _change[' Channel _id '],
' date ' = = $related _change[' Date ',
' program ' = = Array (
' name ' = = $related _change[' program_n Ame '],
' type ' = = $related _change[' Program_type '],
' start_time ' = ' Date (' y-m-d h:i:s ', $related _change[ ' Program_start_timestamp '),
' end_time ' = = Date (' y-m-d h:i:s ', $related _change[' Program_end_timestamp ']),
' duration ' = = (int) $related _change[' Program_end_timestamp ')-(int) $related _change[' Program_start_ Timestamp '],
' source_duration ' = time_to_sec ($related _change[' program_original_duration '),
' Source_ Type ' = = (string) $related _change[' Src_type '),
' source_start_ts ' and ' = ' $related _change[' src_start_time '],
' uri ' = (string) $related _change[' Program_uri '),
)
);
------to solve the idea----------------------
Json_decode () The second parameter is not set to True when the object is returned, and the object should be accessed using the $related _change->user_key. Or pass in the second argument as true, accessed as an array. Write like the 3 floor.