-
Notifications
You must be signed in to change notification settings - Fork 2
Add from_json()
/to_json()
Fix functions.
#242
Conversation
Hm, seems I'm missing something here. That one seems correct, null could not be parsed as JSON, no error_string is given, result is null, seems good. What seems wrong to me is shouldNotConvertInvalidObjectFromJson, which produces "eeny meeny miny moe", but shouldn't it produce null (input is not a quoted string, no error_string given)? And the next one, shouldConvertInvalidObjectFromJsonWithErrorString, should that not be called shouldNotConvertInvalidObjectFromJsonWithErrorString? Are these related to the issue you described here?
Sounds like a good idea. I'm also happy with the direct implementation though, which seems very straightforward. Perhaps we could switch it if/when we first need some config option or encounter a inconsistency. |
It does indeed produce That's also what I was referring to: New value produces new value, So basically: How should JSON
Okay. |
Alright, got it, thanks. I think the current behavior (produce string "null") is good. |
Had a look at the function, the docu and the unit test. What would a use case for this look like? Perhaps a short description of a use case could be added in the docu as example. (not the code) |
Our actual use case for
|
Then go for it! +1 |
You mean describing this rather complex use case in the documentation for |
fc4fd5b
to
709877a
Compare
I think it was a general go for the PR. I agree that our internal use case is not a good example for the documentation. We can always add an example later if we come across something good (like an API or some data that does basically the reverse of this edit: like JSON over OAI-PMH, or embedded JSON in HTML). |
Okay, thanks! |
Open questions:
shouldConvertNullFromJson()
seems counterintuitive; but fixing it would require changing the behaviour ofRecord.transform(String, BiConsumer)
. Also, we'd have to differentiate between value beingnull
anderror_string
beingnull
. One option might be to generate an empty string which could then get at least cleaned up byvacuum()
.to_json()
error behaviour is untested; I have no idea how to conjure up an invalid object ;)@TobiasNx: Do you also want to do a functional review?