I have some JSON files I want to record on MySQL, I read through some of the help topics in SO but I'm having a problem. 1 2 3
My JSON looks like this;
{
"hoursPlayed": 21775,
"communityVisibilityState": 3,
"timeCreated": 1261107470,
"props": [
{
"level": 53,
"quality": 6,
"origin": 0,
},
{
"level": 10,
"quality": 6,
"origin": 0,
}
]
}
I already created the table and its fields, but I can't figure out what to do when it comes to the "props" array in the last entry of the JSON. It is an array in itself and it should have its own MySQL table. Without the "props" part I can read, use json_decode()
and loop through the array to store every other value but "props" part gets me puzzled.
My table should have fields, right?
- hoursPlayed * INT
- communityVisibilityState * INT
- timeCreated * INT
- props * ??
How do I store this in a table in MySQL?
Normally;
mysqli_query($con,"INSERT INTO my_jsonDB (hoursPlayed, communityVisibilityState, timeCreated)
VALUES (21775, 3,1261107470)");
What about in my case?