![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Very simple conversion of hashes to plain Ruby objects. This is great for consuming JSON API's which is what I use it for. Also works in RubyMotion.
Add this line to your application's Gemfile:
gem "dish"
Then run:
$ bundle
Or install it yourself:
$ gem install dish
If you want a to_dish
helper method added to your Hash and Array objects, you can require dish/ext
in your Gemfile:
gem "dish", require: "dish/ext"
Dish fully supports RubyMotion, enabling you to easily consume JSON API's in your Ruby iOS apps.
For installation in RubyMotion, add this line to your project's Gemfile:
gem "dish", require: "dish/motion"
Then run:
$ bundle
And you're good to go.
NOTE: If you're using Dish with the BubbleWrap JSON module, please see below.
hash = {
title: "My Title",
authors: [
{ id: 1, name: "Mike Anderson" },
{ id: 2, name: "Well D." }
],
active: false
}
book = Dish(hash) # or hash.to_dish if you required "dish/ext"
book.title # => "My Title"
book.authors.length # => 2
book.authors[1].name # => "Well D."
book.title? # => true
book.active? # => false
book.other # => nil
book.other? # => false
Values can automatically be coerced, for example into a custom Dish
object or a Time
, for example if you have an updated_at
in the source.
class Author < Dish::Plate; end
class Product < Dish::Plate
coerce :updated_at, ->(value) { Time.parse(value) }
coerce :authors, Author
end
source_products = [
{
title: "Test Product",
updated_at: "2013-01-28 13:23:11",
authors: [
{ id: 1, name: "First Author" },
{ id: 2, name: "Second Author" }
]
},
{
title: "Second Product",
updated_at: "2012-07-11 19:54:07",
authors: [
{ id: 1, name: "Third Author" },
{ id: 2, name: "Fourth Author" }
]
}
]
products = Dish(source_products, Product)
products.first.updated_at # => instance of Time (2013-01-28 13:23:11)
products.first.authors.first # => instance of Author
# If you required "dish/ext", you can also:
products = source_products.to_dish(Product)
# The above example uses an array. You can do the same directly on a hash:
hash = { title: "My Product", updated_at: "2014-01-15 09:12:45" }
product = Dish(hash, Product) # => instance of Product
product = hash.to_dish(Product) # => instance of Product when using "dish/ext"
This is inspired by Hashie's coercion methods.
Have fun!
You can use the Dish::Plate#to_h
method for accessing the original hash. In addition Dish::Plate#to_json
can be used for marshaling JSON if you are using RubyMotion (NSJSONSerialization
is used) or have required the "json" Ruby stdlib.
NOTE: Previously Dish::Plate#to_h
was called Dish::Plate#as_hash
. The Dish::Plate#as_hash
method is now deprecated.
When you use the BubbleWrap gem to parse JSON into a hash, you can't use the
Hash#to_dish
methods directly because the BW::JSON
module returns some sort of hash that hasn't got the methods from the real hash. I'm
fixing this, but in the meanwhile you can achieve the same result by doing this:
BW::HTTP.get("http://path.to/api/books/2") do |response|
json = BW::JSON.parse(response.body.to_s)
book = Dish(json) # This is the actual conversion
title_label.text = book.title
author_label.text = book.authors.map(&:name).join(", ")
end
Feature additions are very welcome, but please submit an issue first, so we can discuss it in advance. Thanks.
git checkout -b my-new-feature
)git commit -am 'Add feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that dish demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.