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

Some say JSON is like JavaScript. What can this even mean? How

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 14
Thread images: 2

File: 1403074833182.jpg (578KB, 1920x1200px) Image search: [Google]
1403074833182.jpg
578KB, 1920x1200px
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 (65KB, 500x750px) Image search: [Google]
acid.jpg
65KB, 500x750px
>>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 posts: 14
Thread images: 2


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.