JSON validation using angularjs - json

I have an instance where i need to validate an uploaded JSON file in the client side (i.e angularJS).
When a user uploads a JSON file. I need to validate the fields in the JSON, like
{"name":"Rohith"}
If this JSON is uploaded then I will have a schema such as
{"field":"name", "type":"String"}
I saw it can be done by ajv. But did not find any suitable examples with angularjs. Is there any other plugin which can do this?

Related

Writing data to an existing file in the host server using http in flutter

I want to make a json file on the server, and then update this json file using flutter http method in my app. I will get user ID, and if the user ID is already present in json file on the server, I just update the content of that items in the json file for this user only. If the user does not exist I add a new block into my json file on the server.
To do this, I first created a json file on the server and passed its url to http.post or http.put, but my json file is still empty. This means I cannot write anything in my json file.
Why?
Could you please let me know how I can achieve this?

ReactJS validate JSON Object with JSON Schema

In my ReactJS app, I want to validate a JSON object coming from API. I have the valid JSON schema and I want to make sure the coming object is in the correct structure before passing it.
Is there any React plugin which I can use for this.
If you want to draw the UI based on the json object after schema validation, then react-json-schema-form is your friend

How does a .json file work in a API call?

I've been doing research in order to write an API for a school project, and when referencing the API documentation of YouTube and Twitter, I see API URLs like this
https://api.twitter.com/1.1/account/settings.json
My understanding was that you execute a method on the backend which will return information to the caller, but I thought those files had to be of extension type .py or .java or whatever language you're using, and JSON was just the return type. I've been unable to find any information on how a .json file works in this example. Is there code in settings.json that is being executed?
JSON is just a format of your data, that you can then use, for example in JavaScript.
It is back-end language independent. By this I mean, that front-end of the application does not care who produced .json file.
Maybe it was Java application, maybe it was Python, or PHP application it does not matter. It can be also static file, with fixed content which just has json format.
After you receive such thing in front-end, you can do with it whatever you want. From your perspective it will be probably some kind of nested array.
In example you provided, I get:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
And it is fine, it's just data you get. It is JSON format - that is true. But you don't care that path has .json in the URL, it could have any extension, what is important is what's inside.
That is a beauty of JSON. You can prepare for yourself static file with mocked data in JSON format, and use it while developing front-end of the application. When you wish, you can have back-end application which will return real data for your app.
You can also see here, how to return json file from PHP:
Returning JSON from a PHP Script
Or here to see how to do it in Python (Django Framework):
Creating a JSON response using Django and Python

How do i get JSON data from a couchDB database and parse it in Xcode?

For Example,
I have a document in my CouchDB database that holds two fields
"password" and "username".
This is the URL for my document:http://127.0.0.1:5984/_utils/document.html?sgram/fdcfc14940fbaa0d86674046ce005107
I want to retrieve the value of these fields from that specific document in CouchDB and parse it in Xcode.
I tried using http-get but it just returns the entire page source.
You want to make a request to this endpoint
http://127.0.0.1:5984/sgram/fdcfc14940fbaa0d86674046ce005107
For a json response from couchdb just don't include _utils/document.html in between. If you do it will give you back the futon html page.

Extjs File upload using json service?

I am using json service(.net RIA service) to push data to server from Extjs. Currently I have a requirement to upload document to server. I saw some examples using form submit to php files.
Is this possible through json service? or Is it necessery to create some server logic where i can accept form submits?
Is it possible to read some binary data from client side and push as json data to server?
In Extjs, File uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead a hidden element containing all the fields is created temporarily and submitted with its target set to refer to a dynamically generated, hidden which is inserted into the document but removed after the return data has been gathered.
Be aware that file upload packets are sent with the content type multipart/form and some server technologies
check : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-hasUpload
Yes it's possible. You should use FileReader to get binary base64 encoded content (FileReader.readAsDataURL(Blob|File)), which you can transfer with JSON.
More insights here: http://www.html5rocks.com/en/tutorials/file/dndfiles/