3
I have the following string saved in the database.
{"key":"save","user":"1","season":"2016","week201549":{"bloco":"Microciclo","day05122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day06122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""}},"week201550":{"bloco":"Microciclo","day07122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day08122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day09122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day10122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day11122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day12122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""},"day13122015":{"z1":"0","z2":"0","z3":"0","z4":"0","z5":"0","z6":"0","z7":"0","terrain":"Terreno","rpe":"7","elevation":"1861","fc":"140","time":"250","distance":"86","training":" ","color":""}},"week201551":{"bloco":"Microciclo","day14122015":
I just couldn’t figure out how to use it, I’d like to take the information week201549->block. I’ve tried json_decode and a lot more things and not from nothing.
I don’t know what to do, or would have some other way to save in the database?
Hello, if I understand your need I believe this link can help you: http://php.net/manual/en/function.json-decode.php
– Raylan Soares
The json placed in the question has a syntax error.
– rray
And what would that mistake be?
– Geovane Krüger
Play this string in jsonlint and change the call to:
json_decode($str) or die(json_last_error_msg())
– rray
I put it in jsonlint: json_decode($str) and returned the following Error: Parse error on line 1: json_decode({ "key" Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'Undefined'
– Geovane Krüger
jsonlint reported a bug?
– rray
Error: Parse error on line 1: json_decode({ "key" Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'Undefined' Source is on Github. Props to Douglas Crockford of JSON and JS Lint and
– Geovane Krüger