There is a file cakes.json
and in its content:
{ "cake": [ {"title":"Cake1","price": "cake price","description":"cake price"}, {"title":"Cake2","price": "cake price","description":"cake price"}, ] };
You need to write it to the variable var cakes
So that when you call alert(cakes.cake[1].title);
the name of the first cake was displayed from the file cakes.json
Tried manipulations of $.getJSON('js/test.json', function(data)
but failed.
json
after the second object after"cake price"}
there should not be a comma ..... and in.$.getJSON('js/test.json'
should also becakes.json
?)). ....... and add the entiregetJSON
function along with your callback - Alexey Shimanskyjson
here json.parser.online.fr and you will see that it breaks ...... or even writeJSON.parse(ВАША_СТРОКА_JSON);
in the consoleJSON.parse(ВАША_СТРОКА_JSON);
and you will also get an error .............. semicolon should not be at the end either - Aleksey Shimanskyперед ключом description
..... I spokeпосле второго объекта после cake price
..... that is, after the line with the object{"title":"Cake2","price": "cake price","description":"cake price"}
must not be a comma. since there is nothing after her anymore - Aleksey Shimansky