Below is the api response:
{
"total": 59198,
"products": [
{
"id": "23423",
"name": {
"German": "s.Oliver BLACK LABE - Damen, Weiß, Größe 44"
},
"brand": "s.Oliver BLACK LABEL",
"image_url": "https://some_url.com",
"category": "Shirts & Tops"
},...
]
}
and i’m using dry-struct
to convert the response
to ruby objects. For that below is the class:
class SomeService < Dry::Struct
include Dry::Types.module
attribute 'id', String
attribute 'brand', String
attribute 'image_url', String
attribute 'category', String
attribute 'name', Strict::hash
end
Notice the attribute name
. The name attribute in the response is json
and for that i’m using Strict::Hash
to convert the json in ruby hash. I’m not sure about it.
Still the response is like this:
{
"brand": "s.Oliver BLACK LABEL",
"name": "{\"German\"=>\"s.Oliver BLACK LABEL - Damen, Weiß, Größe 44\"}"
}
Let me know what am i doing wrong ?