type-parser icon indicating copy to clipboard operation
type-parser copied to clipboard

Would it interesting to be able produce strings from the type instances?

Open Elisedlund opened this issue 11 years ago • 3 comments

Right now there's support for de-serializing types from a string, Would it be interesting to also be able to produce(by serializing) these strings from the type instances? parser.toString(listWithInt) parser.toString(listWithBoolean) parser.toString(mapOfStrings)

example/usecase: saveState { savedState = parser.toString(mapOfStrings) }

loadState { mapOfStrings = parser.parse(savedState,new GenericType<Map<String,String>(){}); }

Elisedlund avatar Apr 24 '14 12:04 Elisedlund

Good question! You mean like for List the parser.toString() would strip off the trailing square brackets [] when calling List.toString(), so it can be parsed back again?

drapostolos avatar Apr 24 '14 15:04 drapostolos

yes.

Elisedlund avatar Apr 25 '14 09:04 Elisedlund

I was thinking such serializing functionality could be put in a separate library (perhaps with a dependency towards type-parser?), to avoid increasing the foot-print of the TypeParser library (So the users of only the parse functionality should not be forced to include the code for serializing as well).

drapostolos avatar Jul 28 '14 22:07 drapostolos