How to parse json correctly?

how to parse json correctly?
как правильно разобрать json ?
function () {
myObj = {
“name”:“John”,
“age”:30,
“cars”: [
{ “name”:“Ford”,“country”:“Ru”,“models”:[ “Fiesta”, “Focus”, “Mustang” ] },
{ “name”:“BMW”,“country”:“En”, “models”:[ “320”, “X3”, “X5” ] },
{ “name”:“Fiat”,“country”:“Au”, “models”:[ “500”, “Panda” ] }
]
}

for (i in myObj.cars) {
   return  myObj.cars[i].name +' ' + myObj.cars[i].country;
    }
}
}

error
ошибка

function (){
myObj = {
“name”:“John”,
“age”:30,
“cars”: [
{ “name”:“Ford”,“country”:“Ru”,“models”:[ “Fiesta”, “Focus”, “Mustang” ] },
{ “name”:“BMW”,“country”:“En”, “models”:[ “320”, “X3”, “X5” ] },
{ “name”:“Fiat”,“country”:“Au”, “models”:[ “500”, “Panda” ] }
]
}

obj = JSON.parse(myObj);
for(var i=0; i<obj.cars.length; i++) {
return obj.cars[i].Name
}
}

found my mistakes
now a new problem, the array does not get over
нашел свои ошибки
теперь новая проблема, массив не перебирается

function (){
var txt =document.childByName("HttprequestServicen").content.httpText

var obj = JSON.parse(txt);

for (i = 0; i < obj.students.length; i++) {
    return obj.students[i].id;
}
}

I only get the first value of the array
получаю только первое значение массива

Using JSON and database in Flipabit can be very simple.

If you describe your task in detail , I can suggest an easy way. If you have any UI screens and more complete data structure, that would help.

For sharing non-public data, you can send me a PM.

st.pma (2.8 MB)

I get this json
I only need student data

получаю такой json
мне нужны только данные студентов

{"success":"studentAllTrue","students":[{"id":"11","studentidold":"1001","studentid":"35653464","lastname":"Pavlenko","firstname":"Vladimir","othername":"Viktorovich","sex":"f","dateofbirth":"2020-08-07 00:00:00.000","placeofbith":"Russia","hometown":"Russia","nationality":"Russian","residence":"hol","programme":"programm","form":"1","classname":"2","house":null,"guardiansname":"Ivan","occupation":"khk","hsenoresidence":"34","contactone":"43546587","contacttwo":"25465786","additionalinfo":"ok"},{"id":"12","studentidold":"1002","studentid":"46578697","lastname":"Smirnova","firstname":"Ekaterina","othername":"Nikolaevna","sex":"m","dateofbirth":"2020-08-07 00:00:00.000","placeofbith":"hg","hometown":"rrrrrrrr","nationality":"Russian","residence":"fgffgfgfgfgf","programme":"bio","form":"2","classname":"2","house":null,"guardiansname":"sdghsdgh","occupation":"dghsdg","hsenoresidence":"hsdghs","contactone":"6457876667","contacttwo":"6789686756","additionalinfo":"ok"},{"id":"13","studentidold":"1003","studentid":"35246","lastname":"Kawaski","firstname":"Kayumi","othername":"yy","sex":"m","dateofbirth":"2020-08-07 00:00:00.000","placeofbith":"Tokyo","hometown":"yru","nationality":"Japan","residence":"yruyr","programme":"air","form":"2","classname":"1","house":null,"guardiansname":"yyyy","occupation":"yuryeu","hsenoresidence":"reuy","contactone":"3576543467","contacttwo":"6478737678","additionalinfo":"no"}]}

login - password === admin - admin

at the beginning, the program checks the session - if there is no session, it proceeds to enter the login and password

в начале программа проверяет сессию - если сессии нет переходит к вводу логина и пароля

I get an error: Timeout exceeded

Is your site working?

Ok. It working now.

How to find out which row in table to highlight in green? Or how to determine the current student in your JSON?

form":“1” == green
form":“2” == red

Here is the video tutorial: import_json.mp4

Project file: st_modified.pma (2.8 MB)

Большое спасибо! оказывается нужно было использовать замену
все действительно оказалось очень просто

Many thanks! it turns out it was necessary to use a replacement
everything really turned out to be very simple


Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.