admin管理员组

文章数量:1180552

Can anyone show me some complex JSON structure and tutorials where i can excel more on this JSON topic using javascript. So far i am able to understand JSON, its basic structure and how to parse and alert out properties.

I can search in google or other search engines, but i want links from you expert guys who can lead me to right direction than a BOT which displays result.

Can anyone show me some complex JSON structure and tutorials where i can excel more on this JSON topic using javascript. So far i am able to understand JSON, its basic structure and how to parse and alert out properties.

I can search in google or other search engines, but i want links from you expert guys who can lead me to right direction than a BOT which displays result.

Share Improve this question asked May 27, 2011 at 22:40 John CooperJohn Cooper 7,61133 gold badges83 silver badges102 bronze badges 3
  • 4 Search Engines like these will take you in the right direction. :) – Praveen Lobo Commented May 27, 2011 at 22:42
  • 7 JSON structure isn't all that complex. You can read about it here: json.org . Your question however is a bit vague. Are you referring to AJAX? Serialization? – onteria_ Commented May 27, 2011 at 22:43
  • 1 instead of learning JSON, learn JavaScript in depth. One good tutorial for you in this series... blogs.sitepoint.com/javascript-json-serialization – Thalaivar Commented May 27, 2011 at 22:50
Add a comment  | 

2 Answers 2

Reset to default 34

Basics

  • Read everything on json.org, including:
    • the code for the standard json2.js,
    • and this page explaining the standard JavaScript JSON.* APIs
    • (Skip the formal definitions for now, and get back to it regularly)
  • Read the corresponding JSON Wikipedia entry
  • Read the Mozilla Developer Docs' JavaScript Reference on:
    • JSON, the JSON object, JSON.parse and JSON.stringify
    • Using native JSON
  • Read blogs and articles:
    • Get Started with JSON
    • JSON: What is is, how it works, how to use it
  • Read slides:
    • Replacing XML with JSON
    • Advanced JSON
    • The JSON saga (Also by Douglas Crockford, creator of JSON and json.org, ECMAScript committee member, and acclaimed writer - see below)
  • Even watch some videos
  • Get to know ECMAScript/JavaScript better:
    • Crockford's essays on JavaScript
    • the ECMAScript ECMA-262 standard, 5th edition
    • Crockford's book JavaScript: the Good Parts
  • Browse StackOverflow:
    • questions on JSON
    • questions on Advanced JSON
    • and also questions on Advanced JavaScript to polish your skills

Get (a lot) more involved...

Check out JSON processors and libraries

If you have some knowledge of other languages, you could look at some JSON processors' implementations and get to know what makes them better or worse than their competitors, read their code, etc...

For instance, for Java:

  • json-lib
  • Jackson
  • google-gson
  • FlexJSON

For other languages: see json.org (at the bottom of the page) for tons of links.

Learn about JSON variants and JSON-based concepts

  • JSONP Wikipedia Entry
  • BSON Wikipedia Entry
  • ...

Experiment with some JSON endpoints

Look online for webservices exposing JSON-enabled endpoints to play with them. Head over to ProgrammableWeb for that, or use any search engine.

For experimenting, use either:

  • Google Chrome and open the Chrome Dev Tools (CTRL+SHIFT+J),
  • Firefox and install and open Firebug (F12),
  • Internet Explorer and open the Debug Tools (F12) (or install Firebug Lite),
  • Alternatively:
    • Google Code Playground to play with some of their services (specifically, try that example for an easy JSONP demo with jQuery),
    • jsFiddle lets you experiment with libraries and share snippets.

Actually you could very much just use your javascript console to experiment without any end-point and test whether you manage to create objects.

JSON has following types of elements:

  • objects (eg. {} or { something: 'somevalue' }, JSON itself),
  • arrays (eg. [] or [1, 'test', false, true, false, 1, 22, 33]),
  • boolean (true or false),
  • integers (eg. 0, 10, -23342),
  • floats (eg. 0.2, 3.1415, -321312.01),
  • null,

So to construct some complicated JSON you can just combine all of the above and assign it to some variable:

var myjson = {
    myame: 'Tadeck',
    myinterests: [
        'programming',
        'games',
        'artificial intelligence',
        'business models'
    ],
    mydata: {
        'age': 'not your business',
        'something': 'das',
        'friends': [
            'A',
            'B',
            'C'
        ]
    },
    facebook_friends_count: 0,
    iq: 74.5,
    answered_your_question: true,
    answer_sufficient: null,
    question_can_be_answered_better: false,
    solutions: [
        'read about JSON',
        'test JSON in JavaScript',
        'maybe test JSON in different languages',
        'learn how to encode some special characters in JSON'
    ]
}

Then play with it in JavaScript and remember that this is the way objects are noted in JavaScript. This is simple, yet very powerful solution (used eg. by Twitter).

If this will not help (btw. again: visit JSON.org), I have one more advice for you: practice.

本文标签: javascriptComplex JSON and TutorialsStack Overflow