object - json
[what]
- ] json stands for javascript object notation,
- ] with json you can create js objects by simply defining them, similar to specify an object literal
- ] with json you can pass objects to ...
- ] you create an object by simply using the kewyord var to create the name and then assigning a set of empty braces {} to that name;
- ] var myObject = {};
- ] the example above wont do much(or anything) at this point but it is a valid js object
- ] the example below to see what the previous object looks like declared using json
- ] did you notice its exactly the same as the object literal declaration of an object
- ] in js an "object" consists of name value pairs, names and values are separted by a colon : and
- ] so if we wanted our object to have an id property, we would give it a name value pair of name=id and value=whatever value that we wanted to assign to the id property
- ] SO for exampled if we wanted name - id , with an id value of 3
- ] var myObject = {id:3}
- ] JSON objects !=== the JSON object
- ] the JSON object - has methods for parsing JSON objects (turning json into objects) and stringify (turning json objects into strings )
[why]
- ] JSON is a data interchange format - typically used to pass application data between .... and ....
[when]
- ] var myCar = JSON.parse(myCarInJson);
- ] var myCarToJson = JSON.stringify(myCar);
[example]
var myObject = {
"name":"dons object",
"function":"getName(){alert(myObject.name);}"
}
[how-to]
- ] if your object has more then 1 property(most all do),
- ] seperate ,each name/value pair with a comma in your object declaration
- ] SO for example, lets add another property to our object named "L1" and assign it the value of "subjects"
- var myObject = {id:3,L1:"subjects"}
- ] if your object has even more properties, just keep on seperating each additional name/value pair with commas
- var myObject = {id:3,L1:"subjects",L2:"objects",L3:"systems"}
[reference]
- ] (id=2736) create art task
- ] http://stackoverflow.com/questions/12440350/create-a-json-object-in-javascript
- ] http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/
003 // OBJECT - JSON
var app = {
name: "subjects",
qryL1: "../qry/Select-Libraries-a.cshtml/",
L1: "Library",
id : $("#id_article").text(),
qryMove: "../qry/updateArticle/",
Destination: "-",
qryCopy:"../qry/copy_records/",
To: $("#parent_id2").val()
};