Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How can I output a json feed!

    I'm quite new to javascript programming, I basically want to parse a JSON string from an external URL.

    http://cashtrackr.com/piwik/index.ph...9d8d472cc9974a

    This is the json string URL and I just want to output the contents of "nb_visits" for example.

    I would also like to know the terms for a JSON string "?" : ?

    thanks for your time

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    JavaScript contains the JSON.parse() method to perform that task however it is a relatively recent addition to the language and so old versions of IE don't support it. If you need to support those browsers as well then see https://github.com/douglascrockford/JSON-js for the code necessary to add that support.

    Douglas Crockford who wrote that code is responsible both for the original invention of JSON and the addition of the JSON.parse into JavaScript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,444
    Thanks
    11
    Thanked 598 Times in 578 Posts
    Quote Originally Posted by felgall View Post
    Douglas Crockford who wrote that code is responsible both for the original invention of JSON and the addition of the JSON.parse into JavaScript.
    Brendan Eich invented JSON, doug discovered and popularized it (according to doug).
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by rnd me View Post
    Brendan Eich invented JSON, doug discovered and popularized it (according to doug).
    I disagree. If Brendan had invented that object then why is it that the place to get the code to add support for the object inantiquated browsers such as IE7 is the page where Douglas offers his code. The code that he offers there is a directl plugin to allow antiquated browsers that don't support the JSON object to implement it with the code first checking if the object already exists and if so then leaving the built in JSON object to be used - since the code his version offers is the majority of what the built in JSON object offers.

    If Brendan had invented the JSON object then it would be his code you'd use to add the support for JSON into IE7 and earlier rather than DOug's.

    Brendan did invent the Object notation that Doug's JSON object uses.

    Your statement is only true with rerspect to JavaScript Object Notation and not to the JSON built in object itself.
    Last edited by felgall; 02-07-2012 at 08:30 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,444
    Thanks
    11
    Thanked 598 Times in 578 Posts
    Quote Originally Posted by felgall View Post
    Your statement is only true with rerspect to JavaScript Object Notation and not to the JSON built in object itself.


    i never said anything about a particular library (one of many) that adds JSON support to a certain language. JS is one of many languages that support json; for example, php has it built-in.

    window.JSON != JSON as a concept

    doug wrote json.js and json2.js (formerly json-sans-eval).

    as doug says in the docs for the javascript json libraries:

    JSON is a light-weight, language independent, data interchange format.
    See http://www.JSON.org/

    The files in this collection implement JSON encoders/decoders in JavaScript.
    so there you go, json.js is but one tool for handling JSON, not the definition of JSON itself.


    JSON == javascript (that's why eval() works on it)
    javascript was invented by brendan. (not disputed)

    ergo, JSON was invented by brendan.


    of course, you don't have to take my word for it, take dougs:
    "I do not claim to have invented JSON. I claim only that I discovered it. It existed in nature. I identified it, gave it a name, and showed how it was useful..."
    Last edited by rnd me; 02-07-2012 at 11:42 PM.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by rnd me View Post
    i never said anything about a particular library
    Neither did I.

    JSON is a native JavaScript static object with two methods - parse and stringify. It is only IE7 and earlier that don't support a recent enough version of JavaScript to support that built in object without a library.

    As that built in object is based on Doug's library, obviously Doug's library should be considered as the official one to use in antiquated browsers that do not support the latest JavaScript.

    The only reason why I mentioned that Doug is the inventor of the JSON object in the first place was as support for the idea that his code is the correct way to add that support for older browsers rather than using an alternate approach.

    You have simply confused all of my references to Doug as the inventor of the JSON object which is now a native part of JavaScript with references to JavaScript Object Notation which as you say was invented by Brendan - which is completely irrelevant to what the OP was asking about.



    So just to make it completely clear:

    JavaScript ( including JavaScript Object Notation) was invented by Brendan Eich
    The JSON object added to JavaScript in the ECMAScript 5 standard was invented by Douglas Crockford. See 15.12.2 of the standards for its definition.

    It is thie JSON.parse() that the OP should use to parse JSON from strings rather than eval() as the parse method includes code to make sure that the text being parsed is actually JSON and not something else that can run as JavaScript.
    Last edited by felgall; 02-08-2012 at 09:39 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #7
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,444
    Thanks
    11
    Thanked 598 Times in 578 Posts
    Quote Originally Posted by felgall View Post
    So just to make it completely clear:

    JavaScript ( including JavaScript Object Notation) was invented by Brendan Eich
    The JSON object added to JavaScript in the ECMAScript 5 standard was invented by Douglas Crockford. See 15.12.2 of the standards for its definition.

    It is thie JSON.parse() that the OP should use to parse JSON from strings rather than eval() as the parse method includes code to make sure that the text being parsed is actually JSON and not something else that can run as JavaScript.
    i agree 100%. sorry to get sidetracked, but i've got Brendan back, so when i see his contributions to mankind diminished (step aside Gutenberg), its not something i can remain neutral on.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • #8
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Try google feed api

    This method has been very useful for me.

    https://developers.google.com/feed/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •