devicescript icon indicating copy to clipboard operation
devicescript copied to clipboard

Support for json in flash?

Open pelikhan opened this issue 1 year ago • 5 comments

Read only json loaded directly from flash?

  • array of literals in flash? number[]

pelikhan avatar Mar 13 '23 14:03 pelikhan

you can do hex `00 01 ...`; what use case do you have in mind?

mmoskal avatar Mar 16 '23 22:03 mmoskal

Say i want to some readonly configuration data encoded as JSON. It would be great to have it stored in flash and not use head at runtime.

const configThatNeverChagnes = json`{
  "adsfasf": "sdfsdf"
}`

pelikhan avatar Mar 16 '23 23:03 pelikhan

I guess it would be more like

const cfg = Object.freeze({ "foo": 1 })

or maybe Object.deepFreeze().

I don't think this is critical though...

mmoskal avatar Mar 16 '23 23:03 mmoskal

In MakeCode, we've had several instances where people had massive array of numbers to implement a driver. These arrays we using heap for now good reason. I would be good to be able to encode these kind of lookup tables in flash.... So maybe not object but something like number[]

pelikhan avatar Mar 16 '23 23:03 pelikhan

I guess we could have Object.freeze([1, 2, 3]) and Object.freeze(new Uint32Array([1, 2, 3])). Anyway, in future...

mmoskal avatar Mar 20 '23 17:03 mmoskal