Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/json-compare/comparer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def compare_elements(old, new)
if old.kind_of? Hash
if new.kind_of? Array
diff_hash = compare_hash_array(old, new)
elsif new.kind_of? String
diff_hash = compare_hash_string(old, new)
else
diff_hash = compare_hashes(old, new)
end
Expand Down Expand Up @@ -76,6 +78,17 @@ def compare_arrays(old_array, new_array)
filter_results(result)
end

def compare_hash_string(old_hash, new_string)
result = get_diffs_struct
if (new_string.include? ",")
return compare_hash_array(old_hash,new_string.split(","))
else
result[:update][0] = new_string
result[:remove][0] = old_hash
end
filter_results(result)
end

def compare_hash_array(old_hash, new_array)
result = get_diffs_struct

Expand Down