If you have more complex case you can use abstract class|interface and produce it’s children for different node types. I define status array in my target type and use adapter which read integer or array from json field and produces array always. For example i have “status” field in server payload which can be array or integer. They gives you “adapters” for serializing|deserializing specified nodes to minify brain damage from case-sensitive node types. Or you can use one of mapping solutions like Gson|Jackson. For example JsonObject tree which is from-the-box solution in jdk. Standard way to map dynamic (badly engeneered) json|xml api payload is to build hierarchical structure. Even using reflection you manipulate already resolved types. But what will you do with those instances out of this script? Every type in your ‘native’ code must be resolved in compile-time, for casting you also use resolved types. For example, you can generate&run kotlin script|java script|python etc from your ‘native’ code and in it you can define new type and produce its instances.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |