Closed madpink closed 8 years ago
Very interesting. This comes from easyJson library. I'm going with it's a bug. "null" is a string. What I believe the JSON definition implies is that null is equivalent to LC's empty. So, if you've made the correction in fastJson go ahead and submit a pull request. I think it's the correct way the library should handle null.
null is a valid value in JSON, it is just specifically in the context of an array that there is a problem...
I'm going to dive through the code to see if there is a more elegant solution for the array to json conversion, but I think that the json to array is going to be more problematic
Fixed in version 1.1.0
I wanted to post this as an issue because it may be an issue for others. I have a couple of quick fixes, but I am not 100% sure they need to be implemented so I am not going to create a pull request. For CouchDB the empty array is important, I believe that it also is for MongoDB. I am not sure about other uses.
Here is an example of what I am trying to produce (this is a user record for CouchDB):
"Roles" needs to be an array, and can only be full of strings or completely empty. Closest I can get is this script:
This is the result:
However, this errors out. For the time being I just have the following to my own script:
Needless to say, the reverse process is also a problem, so I added this step before processing a JSON into an array: