brandonchinn178 / aeson-schemas

Easily consume JSON data on-demand with type-safety
http://hackage.haskell.org/package/aeson-schemas
BSD 3-Clause "New" or "Revised" License
52 stars 1 forks source link

Record object would be AWSOME! #24

Closed mikesol closed 4 years ago

mikesol commented 4 years ago

Sorry, this isn't a bug report, but the library is awesome and I have one feature request.

Would it be possible to add a record type that parsed an object, ie Record Int would be an object where the values were integers.

I can help with implementing it if the idea makes sense - I looked at the code and it looks like it'd be basically the same as List with some slight modifications.

brandon-leapyear commented 4 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


Thanks for using this library! I'm not sure what the benefit of having Record Int would be. Why not just use HashMap Text Int?

Right now, I don't think the code allows for type constructors like that

{
  foo: HashMap Text Int,
}

(which is a good issue to write separately) but you could just make an alias type IntRecord = HashMap Text Int?

mikesol commented 4 years ago

Ah, I didn't realize that the DSL allowed for any type to be in there - I thought it had to follow the convention of using the types predefined in the library (ie List). Thanks for the clarification!

brandon-leapyear commented 4 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


Yup! It should be documented here. Let me know if it can be improved!