Hello guys,
this are two questions in one I think:
In a content form I get distance and duration and fill them as JSON in a text field to store it in my database - it's the same thing like getting values from an API.
So in both cases (database or maybe an API) I have the following simple JSON structure:
{"duration":"123456","distance":"481443"}
When I use a text field now with storage option JSON and Free (pointing two my database column where the JSON is stored) like this:
myfield[duration]
I get the value "123456" shown in a form with myfield.
Question 1:
I only want to display the field and don't want to store the data, is that possible?? To have field in a form, only showing, not storing??
Yes I know the option in the dropdown not to store the value but then I also don't have the option tho point my field to get the right values....
If the data would be stored my JSON-Array in the database get's corrupted because in this case he would store the complete Array now in "duration"...
So I need the option to only display the values...
Question 2:
With the simple JSON-Array from above reading the values in text fields is no problem, but If the structure get's more complex I fail in reading the data. Maybe it's not possible or I'm trying the wrong syntax. Let's say we have JSON data like this:
{
"user":{
"id":78046872,
"name":"TheWhykiki",
"profileIconId":28,
"summonerLevel":1,
"revisionDate":1442412202000
},"distance":"123456"
}
Then I get the distance like before myfield[distance], but If I'm trying to retrieve data from the Array "user" I fail constantly :-)
I want to get the value "id" so I tried
myfield[user[id]]
But I get nothing, the value stays empty but I get no error.
The usage of:
myfield[user]
gives the warning that there is an array not a string. How to get one value from this array to use it??
Thank you very much
Kiki