Gaev wrote:2) Instead of asking for NeoBook commands to parse JSON object's key/value pairs, you can use Javascript's built in JSON parsing capabilities to extract the individual key/value pairs as NeoBook variables.
How would one go about doing this?
I have data formatted in JSON (on disk) that I need to read and parse in Neobook. Since I've only used NeoBook functions in JScript as simple one-to-one functions so far, I'd like to know how to pass complete resulting arrays back to Neobook that are parsed from the JSON file.
Specifically, it's a file with a list of credentials encoded in JSON, each entry having multiple fields. How would I parse the entire thing and then pass back an array?
Example:
- Code: Select all
{
"nextId":15,
"logins":
[
{"id":13, (unique ID)
"hostname":"url.to.host",
"httpRealm":"realm name",
"formSubmitURL":null,
"usernameField":"name-of-field",
"passwordField":"name-of-field",
"encryptedUsername":"===base64-encoded===",
"encryptedPassword":"===base64-encoded===",
"guid":"{00000000-0000-0000-0000-000000000000}",
"encType":1,
"timeCreated":1431036705891,
"timeLastUsed":1431036705891,
"timePasswordChanged":1431036805297,
"timesUsed":1
},
{"id":14,
"hostname":"url.to.host",
"httpRealm":"realm name",
"formSubmitURL":null,
"usernameField":"name-of-field",
"passwordField":"name-of-field",
"encryptedUsername":"===base64-encoded===",
"encryptedPassword":"===base64-encoded===",
"guid":"{00000000-0000-0000-0000-000000000000}",
"encType":1,
"timeCreated":1431036705892,
"timeLastUsed":1431036705892,
"timePasswordChanged":1431036805299,
"timesUsed":4
}
],
"disabledHosts":
[
"http://url1.domain1.com",
"http://url2.domain2.com"
],
"version":1
}
I'd like to get back an array of "logins" and of "disabledHosts", but I'm unsure how to pass back arrays or pull the data out of the JSON data format. The rest is rather inconsequential and doesn't need to be retained.