### Home Classes Methods

### In Files

- lib/yajl/json_gem/encoding.rb
- lib/yajl/json_gem/parsing.rb

### Namespace

- CLASS JSON::GeneratorError
- CLASS JSON::JSONError
- CLASS JSON::ParserError

### Methods

- ::default_options
- ::dump
- ::generate
- ::load
- ::parse
- ::pretty_generate

### Files

- README.rdoc
- Makefile

### Class/Module Index

Quicksearch

- Yajl
- Yajl::Bzip2
- Yajl::Bzip2::StreamReader
- Yajl::Bzip2::StreamWriter
- Yajl::Deflate
- Yajl::Deflate::StreamReader
- Yajl::Deflate::StreamWriter
- Yajl::EncodeError
- Yajl::Encoder
- Yajl::Gzip
- Yajl::Gzip::StreamReader
- Yajl::Gzip::StreamWriter
- Yajl::HttpStream
- Yajl::HttpStream::HttpError
- Yajl::HttpStream::InvalidContentType
- Yajl::ParseError
- Yajl::Parser
- Yajl::Stream
- JSON
- JSON::GeneratorError
- JSON::JSONError
- JSON::ParserError
- Array
- FalseClass
- Fixnum
- Float
- Hash
- Kernel
- NilClass
- Object
- String
- TrueClass

No matching classes.

# JSON

### Public Class Methods

default_options() click to toggle source

    # File lib/yajl/json_gem/parsing.rb, line 7
    def self.default_options
      @default_options ||= {:symbolize_keys => false}
    end

dump(obj, io=nil, *args) click to toggle source

    # File lib/yajl/json_gem/encoding.rb, line 42
    def self.dump(obj, io=nil, *args)
      begin
        Yajl::Encoder.encode(obj, io)
      rescue Yajl::EncodeError => e
        raise JSON::GeneratorError, e.message
      end
    end

generate(obj, opts={}) click to toggle source

    # File lib/yajl/json_gem/encoding.rb, line 18
    def self.generate(obj, opts={})
      begin
        options_map = {}
        if opts.has_key?(:indent)
          options_map[:pretty] = true
          options_map[:indent] = opts[:indent]
        end
        Yajl::Encoder.encode(obj, options_map)
      rescue Yajl::EncodeError => e
        raise JSON::GeneratorError, e.message
      end
    end

load(input, *args) click to toggle source

    # File lib/yajl/json_gem/parsing.rb, line 19
    def self.load(input, *args)
      begin
        Yajl::Parser.parse(input, default_options)
      rescue Yajl::ParseError => e
        raise JSON::ParserError, e.message
      end
    end

parse(str, opts=JSON.default_options) click to toggle source

    # File lib/yajl/json_gem/parsing.rb, line 11
    def self.parse(str, opts=JSON.default_options)
      begin
        Yajl::Parser.parse(str, opts)
      rescue Yajl::ParseError => e
        raise JSON::ParserError, e.message
      end
    end

pretty_generate(obj, opts={}) click to toggle source

    # File lib/yajl/json_gem/encoding.rb, line 31
    def self.pretty_generate(obj, opts={})
      begin
        options_map = {}
        options_map[:pretty] = true
        options_map[:indent] = opts[:indent] if opts.has_key?(:indent)
        Yajl::Encoder.encode(obj, options_map)
      rescue Yajl::EncodeError => e
        raise JSON::GeneratorError, e.message
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.