[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Some say JSON is like JavaScript. What can this even mean? How
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

Thread replies: 14
Thread images: 2
File: 1403074833182.jpg (578 KB, 1920x1200) Image search: [Google]
1403074833182.jpg
578 KB, 1920x1200
Some say JSON is like JavaScript.

What can this even mean?
How can a data format be like a programming language??

Also, how does JSON differ from an (algebraic) data type? Like trees.
>>
>>8105722
yes
>>
>>8105722
no
>>
>>8105722
maybe
>>
>>8105722
i dont know
>>
>>8105722
can you repeat the question
>>
>>8105722
YOURE NOT THE BOSS OF ME NOW
>>
>>8105722
>Some say

who?
>>
File: acid.jpg (65 KB, 500x750) Image search: [Google]
acid.jpg
65 KB, 500x750
>>8105750
https://en.wikipedia.org/wiki/JSON
>JSON is a language-independent data format. It derives from JavaScript, but as of 2016, code to generate and parse JSON-format data is available in many programming languages. The official Internet media type for JSON is application/json. The JSON filename extension is .json.

and also
http://stackoverflow.com/questions/8294088/javascript-object-vs-json

and other questions on SE.

Doesn't make sense to me. That said, while I know some Java, I don't know more Java script than code examples on the web.
>>
>>8105722
>Some say JSON is like JavaScript.

>What can this even mean?

Possibly they are referring to the fact that it's not a particularly efficient format, in that half the space is used to store the names of variables and sometimes white space to format it.

That's hardly a bad thing though, as storage and bandwidth is cheap and more efficient ways of storing data often fall over when you want to change what is stored while still keeping things backwards compatible. It's also still pretty efficient when compared to things like XML.
>>
JSON = "JavaScript Object Notation". It's JavaScript's syntax for literal values (strings, numbers, arrays, and "objects" i.e. dictionaries).

In JavaScript, you can (but shouldn't) parse JSON data simply by eval()ing it. That's how JSON came into existence in the first place: as a format which can be read by JavaScript code without having to write a parser for it.

The reason why you shouldn't do that is because eval() will also execute arbitrary code, which is a problem if the data comes from an untrusted source.

The original solution was to first use a regexp to ensure that the string contained only literal values (and not function calls), and assuming that it matched, eval() it. More recent versions of JavaScript have JSON.parse().
>>
>>8105783
> in that half the space is used to store the names of variables and sometimes white space to format it.
I don't understand. Do you mean keys in keylists? Where are names wasting space in JSON?

>>8105785
Can you give an example of how eval works for JSON vs. for other javascript expressions?
>>
>>8105902

For example, '{"TestValue":12345678}' takes 22 bytes to store/transfer a 4 byte value.

Again, however, this is just a guess at what could be meant by saying JSON (as a data format) is like Javascript (as a language). It's not the most efficient way to do things, but that doesn't mean it's useless.
>>
nump
Thread replies: 14
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.