module JSON::OnSteroids::InPlace
Direct including types
Defined in:
json_on_steroids/in_place.crInstance Method Summary
- #delete(key : Int | String | Nil)
- #delete
- #set(value)
-
#set(&)
Mutate in place a value.
Instance Method Detail
def set(&)
#
Mutate in place a value.
Example:
# increment by one a visitor counter
json.dig("data.visitors.count").set(&.as_i.+(1))
Other example:
json["some"]["array"].as_arr.each{ |x| x.set("Hellow #{x.to_s}") }
Any authorized value can be passed (see JSON::Any::Mutable::AuthorizedSetTypes)