JSON - Validate Form Data - json

I used xml earlier and learning JSON now. To restrict the user to enter garbage values for form fields such as address etc, in XML we can define a complex object in schema file. But using JSON How can do that? JSON accepts any data from the user. Could any one please provide me ideas or an example code?
Thanks in Advance.

it is possible to do validation with schemas in JSON :
http://en.wikipedia.org/wiki/JSON#JSON_Schema
depending on what you need to validate :
http://json-schema.org/latest/json-schema-validation.html
Online tool for testing :
http://www.jsonschema.net/

Related

Is there a way to generate json data from json schema with multi source json data?

I am currently working with a project to implement data fusion / data integration. Now I can find the technology to get json schemas from json data. But how could I integrate different json attributes into the target json schema. My final target is to implement the json data fusion by configuration on a web page. Is there any solution or any open source implementation I could take referrence? Thank you so much.
Please allow me to explain it more clearly. I could define a target json schema, and its attributes should be filled by other json data's attributes (the json may come from multi source).

How to validate against a definition within a schema?

I want to have a single schema file with many definitions.
I then want to validate messages against different definitions within that schema.
Is there a way of doing this with a JSON Schema?
I'm trying two NodeJS validators to see which works best:
https://github.com/geraintluff/tv4
and https://github.com/tdegrunt/jsonschema
Apologies if this is not logically possible - I'm new to JSON Schema.
Cross-posted to https://github.com/geraintluff/tv4/issues/170 and https://github.com/tdegrunt/jsonschema/issues/94
I found what I needed in the API section.
tv4.addSchema() and tv4.getSchema(...#subschema_id')

Lotus Domino data as JSON

My object is to be able to get the data from a notesdocument as JSON
This I can do by using the Domino Data Service via the URL.
The rich text fields are translated to HTML but gets contentTransferEncoding: "quoted-printable"
Is there any way I can avoid that?
Alternatively - another method with which I can get json from all the types of fields in a document - using XPages or java?
Thanks in advance
Maybe DomJson by Michael Nielsen can help you. It is similar in functionality as Domino Data Service but might offer what you need with regards to rich text fields. If not, then you can extend it to your needs since it's open source :-)

POSTing data to a server with jQuery - why use JSON?

All over the net I see examples of using jQuery to make AJAX POSTs of JSON encoded data to a server. What is the point of encoding the data in JSONfirst? Why not just send it as the default data type application/x-www-url-form-encoded which would save having to parse JSON data on the server?
Couple of reasons. One, it's very easy to turn a JavaScript object into JSON, while it takes effort to encode it as x-www-url-form-encoded. Also, x-www-url-form-encoded isn't really used that much any more. Besides the couple of input types that require a form, most things use AJAX nowadays. Also, JSON is much easier to debug because it's legible.
First, you don't have to use json. If you are more comfortable using any other format, then use it.
But keep in mind, it's all strings. And sometimes it makes sense to use a format like JSON. What happens if you form is dynamic, and you enter multiple instances of the same thing (e.g. name1, name2, name3....)? It's really easy to iterate over such things with JSON. And JSON parsers are readily available for all platforms, so it's not like using it is a hinderance on any platforms. Plus, if both submissions and responses use the same format, there is the benefit of consistency for the data in requests and responses.
JSON is short for JavaScript Object Notation, and is a way to store information in an organized, easy-to-access manner.In a nutshell, it gives us a human-readable collection of data that we can access in a really logical manner.
We use JSON encoding to organize stored information.
Example:
var jason = {
"age" : "24",
"hometown" : "Missoula, MT",
"gender" : "male"
};
To access the information stored in json, we can simply refer to the name of the property we need.
Result:
document.write('Json is ' json.age); // Output: Jason is 24

Is it possible to write data to JSON with Extjs4?

Is it possible to write data to JSON without php/asp, only ExtJS? Can someone provide simple example of how to do this (sending form data to Json)?
Where do you want to store your json data exactely ?
Since you don't want to use a server-side script to back it up, I presume it's client-side.
Then I'd say a combination of Ext.data.writer.Json + one of the following :
Ext.data.proxy.LocalStorage
Ext.data.proxy.Memory
Ext.data.proxy.SessionStorage