Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

json(n) [osx man page]

json(n) 							       JSON								   json(n)


json - JSON parser SYNOPSIS
package require Tcl 8.4 package require json ?1.1? ::json::json2dict txt _________________________________________________________________ DESCRIPTION
The json package provides a simple Tcl-only library for parsing the JSON data exchange format as specified in RFC 4627 There is some ambiguity in parsing JSON because JSON has type information that is not maintained by the Tcl conversion. The json package returns data as a Tcl dict. Either the dict package or Tcl 8.5 is required for use. COMMANDS
::json::json2dict txt Parse JSON formatted text txt into a Tcl dict and return the value. EXAMPLES
An example of a JSON array converted to Tcl. A JSON array is returned as a single item with multiple elements. [ { "precision": "zip", "Latitude": 37.7668, "Longitude": -122.3959, "Address": "", "City": "SAN FRANCISCO", "State": "CA", "Zip": "94107", "Country": "US" }, { "precision": "zip", "Latitude": 37.371991, "Longitude": -122.026020, "Address": "", "City": "SUNNYVALE", "State": "CA", "Zip": "94085", "Country": "US" } ] => {Country US Latitude 37.7668 precision zip State CA City {SAN FRANCISCO} Address {} Zip 94107 Longitude -122.3959} {Country US Latitude 37.371991 precision zip State CA City SUNNYVALE Address {} Zip 94085 Longitude -122.026020} An example of a JSON object converted to Tcl. A JSON object is returned as a multi-element list (a dict). { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "", "Height": 125, "Width": "100" }, "IDs": [116, 943, 234, 38793] } } => Image {IDs {116 943 234 38793} Thumbnail {Width 100 Height 125 Url} Width 800 Height 600 Title {View from 15th Floor}} BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category json of the Tcllib SF Trackers []. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
data exchange, exchange format, javascript, json CATEGORY
CGI programming COPYRIGHT
Copyright (c) 2006 ActiveState Software Inc., 2009 Thomas Maeder, Glue Software Engineering AG json 1.1 json(n)

Check Out this Related Man Page

Template::Plugin::JSON::Escape(3pm)			User Contributed Perl Documentation		       Template::Plugin::JSON::Escape(3pm)

Template::Plugin::JSON::Escape - Adds a .json vmethod and a json filter. SYNOPSIS
[% USE JSON.Escape( pretty => 1 ) %]; <script type="text/javascript"> var foo = [% foo.json %]; var bar = [% json_string | json %] </script> or read in JSON [% USE JSON.Escape %] [% data = JSON.Escape.json_decode(json) %] [% data.thing %] DESCRIPTION
This plugin allows you to embed JSON strings in HTML. In the output, special characters such as "<" and "&" are escaped as "uxxxx" to prevent XSS attacks. It also provides decoding function to keep compatibility with Template::Plugin::JSON. FEATURES
USE JSON.Escape Any options on the USE line are passed through to the JSON object, much like "to_json" in JSON. json vmethod A ".json" vmethod converts scalars, arrays and hashes into corresponding JSON strings. [% json_stuct = { foo => 42, bar => [ 1, 2, 3 ] } %] <script> var json = [% json_struct.json %]; </script> <span onclick="doSomething([% json_struct.json %]);"> json filter A "json" filter escapes "<", ">", "&", "+", "U+2028" and "U+2029" as "uxxxx". In the attribute, you may just use an "html" filter. [% json_string = '{ "foo": 42, "bar": [ 1, 2, 3 ] }' %] <script> var json = [% json_string | json %]; </script> <span onclick="doSomething([% json_string | html %]);"> json_decode method A "json_decode" method allow you to convert from a JSON string into a corresponding data structure. [% SET json_struct = JSON.Escape.json_decode(json_string) %] [% | html %] SEE ALSO
Template::Plugin::JSON, JSON, Template::Plugin VERSION CONTROL <> AUTHOR
nanto_vi (TOYAMA Nao) <> COPYRIGHT &; LICENSE Copyright (c) 2011 nanto_vi (TOYAMA Nao). Copyright (c) 2006, 2008 Infinity Interactive, Yuval Kogman. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. perl v5.14.2 2011-06-13 Template::Plugin::JSON::Escape(3pm)
Man Page