Serialize vs. Json - json

Now i am creating Ajax app and i want to know what is better to connect server data with client.
Last time i used json but some time ago i hear that serialized data is faster.
Who know what is better?

In general, a serialized binary representation will be smaller than a JSON representation of the same object (that in turn would be smaller than an XML representation).
In this regards, network transfers would be faster.

Probably you're comparing serialize (working similarly in PHP) and json on your client (a browser). There's a serialize function (similar to how PHP works) in jquery but no native unserialize. I suggest you work with json when communication is between your server and your client (ajax).

Related

When to rturn Json data over simple Ado.Net data return?

In Asp.Net MVC now more trend is returning Json data over simple returning of data in the View.
Why returning of Json data is preferred?
Here several facts that support your statement of preferring JSON over data.
It is much more helpful when working with client side scripting.
If you use ajax call json data is much more readable than class object.
Almost all browser supports it.
It is developer friendly.
Parsing complex data object to json is easier and convinient.

How do I store nested JSON objects directly in ABAP DDIC?

ABAP Databases, oracle, MaxDB et al., are mostly RDBMS. Right now, I have a JSON structure that cannot be normalised and hence I want to store it as is. So, I want a MongoDB like Object store in ABAP.
What's the best way to achieve this? Is data cluster an option? Perhaps the only option?
I don't think you can connect to some other then supported DBs directly from ABAP. If you have Netweaver Java, you can call some custom Java application, which accesses MongoDB. You can check SAP Hana if there is something similar.
In ABAP you interact with RDBMS via ABAP Dictionary.
It supports data types like LCHR, STRING, RAWSTRING. Checkout docs for more details.
Data cluster is one option, but you can simply use a binary type DB field for storing the JSON data.
There is a method called transformation in ABAP, which converts from ABAP data to XML/JSON data and vice-versa.
There's a simple example on the following blog:
https://blogs.sap.com/2013/07/04/abap-news-for-release-740-abap-and-json/
Comments on the blog page contain more info.

Why Play Framework uses JSON why MongoDb uses BSON

I encountered many troubles of dealing with serializing/deserializing Scala data types to/from JSON objects and then store them to/from MongoDB in BSON form.
1st question: why Play Framework uses JSON why MongoDb uses BSON.
2nd question: If I am not wrong, Javascript does not have readers and writers for serializing/deserializing BSON from MongoDB. How can this happen? Javascript can seamlessly handle JSON, but for BSON I expect it needs some sort of readers and writers.
3rd question: (I read somewhere) why Salat and ReactiveMongo uses different mechanisms to talk to MongoDB.
JSON is a widely used format for transfer data in this days. So pretty good to have it "from the box" in the web framework. That is the reason Play has it.
The same reason mongo use it - it is a good idea to store data in the same format as user query it and save it. So Why mongo use BSON but JSON ? Well, BSON is the same as JSON but have additional properties on every value - data length and data type. The reason of this - when you are looking a lot of data (like db query do) you need to read all the object in JSON to get to another one. We can skip reading in the case if we will know the length of the data.
So You just do not need any BSON readers in JS (it could be somewhere but rarely used) because BSON is format for inside DB usage.
you can read this article for more inforamtion

JSON validation against a schema (Java EE application)

I have a use case where I need to validate JSON objects against a schema that can change real time..
Let me explain my requirements..
I persist JSON objects (MongoDB).
Before persisting I MUST validate the data type of some of the
fields of JSON objects (mentioned in #1) against a schema.
I persist the schema in mongodb.
I always validate the JSON objects against the latest schema available in db. (so I dont think it matters much even if the schema can change in real time for me it is kinda static).
I am using a J2EE stack (Spring Framework).
Can anyone guide me here..?
Another way of doing it is to use an external library https://github.com/fge/json-schema-validator to do the work for you. The one I proposed supports draft 4 of JSON Schema.
The IBM DataPower appliance has JSON Schema validation support. This will allow you to offload validation to an appliance that is designed for it along with routing of data within te enterprise.

Nodejs connect to database or REST service

I have to choice to output the info in database (Mysql) to be json format.
directly connect to database and fetch the data and output json
connect to a REST service to get the data and output json.
Which is better and why?
directly connect to database and fetch the data and output json
If you are connecting to the database (doesn't matter if it's MySQL or something else) directly through binary based protocol it should be faster than REST based protocol.
connect to a REST service to get the data and output json.
REST based protocols are on the other hand more simple, straightforward and easier to implement from the client side of view than binary ones in general.
Which is better and why?
It depends if you need speed or simplicity of use. In case of binary connection you would additionaly have to parse fetched data to JSON. REST service can give you usually just what you need in desired JSON format. However if speed is crucial for you then binary protocol is better choice I would say.