[Json] What is Json?

JAsmine_log·2024년 10월 20일
0

What is Json?

JSON

JavaScrip Object Notaition으로, Javascript 객체 문법으로 구조화된 데이터교환 형식이다. 여러 언어에서 사용되며, 단순배열, 문자열도 표현이 가능하다.

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

Javascrip 객체 문법(구조)

  1. key:value pair로 구성되어 있으며, key 값은 중복되지 않게 사용해야 한다. key에 대응하는 value가 새로 할당될 경우, 가장 마지막 값으로 저장된다. 이는 object, record, struct, dictionary, hash table, keyed list, associative array로 인식한다.
  2. 또한, 순서가 있는 값의 리스트이다. 대부분의 언어에서 이를 array, vector, list, sequence로 이해한다.

A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

Json Form

Object form

An unordered set of name/value pairs. An object begins with {left brace and ends with }right brace. Each name is followed by :colon and the name/value pairs are separated by ,comma.

{"firstName":"John", "lastName":"Doe"}

Array form

An ordered collection of values. An array begins with [left bracket and ends with ]right bracket. Values are separated by ,comma.

"employees":[
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]

Value form

A string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

String form

A sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.

Number form

Very much like a C or Java number, except that the octal and hexadecimal formats are not used.

White Space

Inserted between any pair of tokens. Excepting a few encoding details, that completely describes the language.

Json Grammar in McKeeman Form

json
  element

value
  object
  array
  string
  number
  "true"
  "false"
  "null"

object
  '{' ws '}'
  '{' members '}'

members
  member
  member ',' members

member
  ws string ws ':' element

array
  '[' ws ']'
  '[' elements ']'

elements
  element
  element ',' elements

element
	ws value ws

string
  '"' characters '"'

characters
  ""
  character characters

character
  '0020' . '10FFFF' - '"' - '\'
  '\' escape

escape
  '"'
  '\'
  '/'
  'b'
  'f'
  'n'
  'r'
  't'
  'u' hex hex hex hex

hex
  digit
  'A' . 'F'
  'a' . 'f'

number
  integer fraction exponent

integer
  digit
  onenine digits
  '-' digit
  '-' onenine digits

digits
  digit
  digit digits

digit
  '0'
  onenine

onenine
  '1' . '9'

fraction
  ""
  '.' digits

exponent
  ""
  'E' sign digits
  'e' sign digits

sign
  ""
  '+'
  '-'

ws
  ""
  '0020' ws
  '000A' ws
  '000D' ws
  '0009' ws

Reference
[1] https://www.json.org/json-en.html
[2] https://www.w3schools.com/whatis/whatis_json.asp#:~:text=JSON%20stands%20for%20JavaScript%20Object,describing%22%20and%20easy%20to%20understand
[3] https://www.youtube.com/watch?v=Qi2LJ_NfzC0

profile
Everyday Research & Development

0개의 댓글