module JSON::Pure::Generator::GeneratorMethods::Array

Private Instance Methods

json_transform(state) click to toggle source
# File lib/tungsten/common.rb, line 153
def json_transform(state)
  valid_keys = 0
    
  delim = ','
  delim << state.array_nl
  result = '['
  result << state.array_nl
  depth = state.depth += 1
  first = true
  indent = !state.array_nl.empty?
  each { |value|
    json = value.to_json(state)
    if json == ""
      next
    end
    valid_keys = valid_keys+1
      
    result << delim unless first
    result << state.indent * depth if indent
    result << json
    first = false
  }
  depth = state.depth -= 1
  result << state.array_nl
  result << state.indent * depth if indent
  result << ']'
    
  if valid_keys == 0 && depth != 0
    return ""
  end
    
  result
end