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

failability of parsing code

Open Licenser opened this issue 2 years ago • 2 comments

          although I really do think there should be a discussion about the safety of the parsing code, why is parse fallible, and why we parse the array, without having the values of the array in the first place

Originally posted by @NightMare-Vortex in https://github.com/simd-lite/simd-json-derive/issues/54#issuecomment-1783574836

Licenser avatar Oct 28 '23 12:10 Licenser

I agree, definetly worth considering and revisiting! I pulled this in it's own issue so it's nut buried in a completed PR :)

Licenser avatar Oct 28 '23 12:10 Licenser

a few startingpoints:

  1. the tape is (assuming no bugs) guaranteed to be valid JSON, all validation from formating (numbers, strings etc) and structure (correct k/v of objects, correct nesting etc) are checked in the second stage of parsing

  2. for derives we need fallibility as we can have a valid json that does not match the expected structure that the derive demands

  3. for DOM like structures (owned::Value, borrowed::Value that cover the entire JSON value space) we can expect all translation from tape -> dom to be correct

  4. for DOM like structures that may not cover the entire value space, there is a chance of failures

Licenser avatar Oct 28 '23 12:10 Licenser