usp
usp

Reputation: 797

How can I make the JSON data accessible only to my java script?

I am designing a web application that needs to visualize large amount of data as Charts. I found some javascript libraries [dynagraph] that can do this. But the issue is that if I use javascript to access the data [JSON format], anybody can modify the javascript[using tools like 'developer tools' in Google Chrome] and get the data!! So, is there anyway to prevent this?

Thanks

Upvotes: 2

Views: 195

Answers (3)

dvir
dvir

Reputation: 5115

The answer is No. JavaScript code is being ran on the client side, as you said, and that means any data it might access will be in the hands of the client.

What you can do is pass information to a server side script that will generate your chart, and send you back only the non-private information to be displayed.

Upvotes: 4

dodexahedron
dodexahedron

Reputation: 4657

Any data you pass to the client can be tampered with on the client, no matter what technology you're using.

If you are accepting unvalidated input from a client, then you are inviting trouble.

You need to validate the data that the client sends back on the server side, to ensure that the values are sane and match up with business rules.

Upvotes: 0

Cranio
Cranio

Reputation: 9847

Yes, don't use Javascript but some server-side tools. Whenever you use data client-side, your data can be read.

Upvotes: 2

Related Questions