Class | Chef::JSONCompat
In: | lib/chef/json_compat.rb
Parent: | Object

### Methods

class_for_json_class from_json map_hash_to_rb_obj map_to_rb_obj opts_add_max_nesting to_json to_json_pretty

### Constants

JSON_MAX_NESTING | = | 1000
JSON_CLASS | = | "json_class".freeze
CHEF_APICLIENT | = | "Chef::ApiClient".freeze
CHEF_CHECKSUM | = | "Chef::Checksum".freeze
CHEF_COOKBOOKVERSION | = | "Chef::CookbookVersion".freeze
CHEF_DATABAG | = | "Chef::DataBag".freeze
CHEF_DATABAGITEM | = | "Chef::DataBagItem".freeze
CHEF_ENVIRONMENT | = | "Chef::Environment".freeze
CHEF_NODE | = | "Chef::Node".freeze
CHEF_ROLE | = | "Chef::Role".freeze
CHEF_SANDBOX | = | "Chef::Sandbox".freeze
CHEF_RESOURCE | = | "Chef::Resource".freeze
CHEF_RESOURCECOLLECTION | = | "Chef::ResourceCollection".freeze
CHEF_WEBUIUSER | = | "Chef::WebUIUser".freeze
CHEF_OPENIDREGISTRAION | = | "Chef::OpenIDRegistration".freeze

### Public Class methods

class_for_json_class(json_class)
from_json(source, opts = {})

Just call the JSON gem‘s parse method with a modified :max_nesting field

map_hash_to_rb_obj(json_hash)
map_to_rb_obj(json_obj)

Look at an object that‘s a basic type (from json parse) and convert it to an instance of Chef classes if desired.

opts_add_max_nesting(opts)

See CHEF-1292/PL-538. Increase the max nesting for JSON, which defaults to 19, and isn‘t enough for some (for example, a Node within a Node) structures.

to_json(obj, opts = nil)
to_json_pretty(obj, opts = nil)

[Validate]