simd-json-derive icon indicating copy to clipboard operation
simd-json-derive copied to clipboard

Ability to skip over _ prefixed fields

Open v1gnesh opened this issue 1 year ago • 2 comments

How big of a task is it to skip over these fields when deriving Serialize?

Ex:

struct Ye {
    a: u16,
    _b: u8,
    c: u32,
}

should produce

{ "Ye":
  { 
    "a": 0,
    "c": 0
  }
}

v1gnesh avatar Aug 05 '24 15:08 v1gnesh

I don't think it's a big task, but I'm not convinced we should do it. People might very well expect them to be included, especially since serde includes them as well.

Perhaps a better alternative would be to support the skip attribute? (which too isn't a big one I think)

Licenser avatar Aug 05 '24 15:08 Licenser

adding skip in here https://github.com/simd-lite/simd-json-derive/blob/0bca4d4e336667a82469574e684bd3d97e09fbe4/simd-json-derive-int/src/args.rs#L16 should be rather stright forward :) we already have the much more complex skip_serializing_if

Licenser avatar Aug 05 '24 15:08 Licenser