Sha256: 538db31f410bd35be4828955519a1cbe5d898dc3d6af77a5742f052954beb0ad
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
# ----------------------------------------------------------------------- # Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved. # ----------------------------------------------------------------------- require 'json/pure' require 'App42ResponseBuilder.rb' require 'log/Log.rb' module App42 module Log # # # LogResponseBuilder class converts the JSON response retrieved from the server # to the value object i.e Log # # class LogResponseBuilder < App42ResponseBuilder # # Converts the response in JSON format to the value object i.e Log # # @param json # - response in JSON format # # @return Log object filled with json data # # def buildResponse(json) puts "testing #{json}" logObj = Log.new() messageList = Array.new logObj.messageList= messageList logObj.strResponse=json jsonObj = JSON.parse(json) jsonObjApp42 = jsonObj.fetch("app42") jsonObjResponse = jsonObjApp42.fetch("response") logObj.isResponseSuccess = jsonObjResponse.fetch("success") jsonObjLog = jsonObjResponse["logs"] if jsonObjLog.key?("log") == false return logObj; end if jsonObjLog.fetch("log").instance_of?(Hash) # Only One attribute is there jsonObjLogMessage = jsonObjLog.fetch("log") messageItem = App42::Log::Message.new(logObj) buildObjectFromJSONTree(messageItem, jsonObjLogMessage); else jsonObjMessageArray = jsonObjLog.fetch("log") # There is an Array of attribute jsonObjMessageArray.length.times do |i| # Get Individual Attribute Node and set it into Object jsonObjLogMessage = jsonObjMessageArray[i] messageItem = App42::Log::Message.new(logObj) buildObjectFromJSONTree(messageItem, jsonObjLogMessage); end end return logObj; end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
App42_RUBY_SDK-0.8.3 | lib/log/LogResponseBuilder.rb |