dasch-swiss / dsp-api

DaSCH Service Platform API
http://dasch-swiss.github.io/dsp-api/
Apache License 2.0
74 stars 18 forks source link

Maybe we should omit properties with 'null' values in JSON responses #570

Open subotic opened 7 years ago

subotic commented 7 years ago

Currently, whenever we have a None value to an optional property, the Scala2JSON converter creates properties with Null values. This is enabled by the NullOptions trait attached to the corresponding JSON protocol.

A stricter checking in Salsah would be made possible if those properties would simply be omitted, instead of given a Null value.

Before:

{
    'userData': {
        'email': 'multi.user@example.com',
        'firstname': 'Multi',
        'lastname': 'User',
        'isActiveUser': true,
        'lang': 'de',
        'password': null,
        'token': null,
        'user_id': 'http://data.knora.org/users/multiuser'
    }
}

After:

{
    'userData': {
        'email': 'multi.user@example.com',
        'firstname': 'Multi',
        'lastname': 'User',
        'isActiveUser': true,
        'lang': 'de',
        'user_id': 'http://data.knora.org/users/multiuser'
    }
}
benjamingeer commented 7 years ago

We did this to imitate the old SALSAH as closely as possible. I think some of the JavaScript code may depend on this.

In API v2 we should definitely not have nulls in JSON.