Skip to content

Repo API: Property value encondings #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
enikao opened this issue Nov 11, 2022 · 4 comments
Closed

Repo API: Property value encondings #34

enikao opened this issue Nov 11, 2022 · 4 comments

Comments

@enikao
Copy link
Contributor

enikao commented Nov 11, 2022

Possible property value encondings

Encode everything as string

  • Uniform handling
  • Can encode everything
  • Issue: especially structured JSON values would be dumped into a string inside a JSON structure
  • Diffing is easy
  • We don’t expect serious performance issues from encoding boolean/integer as string
  • Doesn't waste too much space

Use JSON types

  • Natural representation for boolean, strings
  • Issue: JSON number vs. Integer
    • If metamodel says property is of type int, but JSON contains 42.1
    • If int value is > 53 bit, JSON loses precision

=> Decision: for JSON transport, all primitive types are strings
Might be different for e.g. protobuf transport

@joswarmer
Copy link
Contributor

Agreed that they should be strings, but shouldn't we say something about the format of the strings for each property type? E.g. a date property is in the ISO8601 format?

@enikao
Copy link
Contributor Author

enikao commented Jan 16, 2023

Agreed that they should be strings, but shouldn't we say something about the format of the strings for each property type? E.g. a date property is in the ISO8601 format?

Per #9, we only have support the default types int, boolean, string (and maybe JSON, tbd).
We had some discussion around things like date, but postponed it (see #10, #20) -- it's not required for the first version.

The closest we got was something like:

@Implementation(Java, "java.util.Date")
@Implementation(Typescript, "http://no.idea/how:this.works.in.ts")
typedef Date: JSON

meaning:

  • There is a typedef called Date
  • It's stored as JSON primitive type (this precedes the decision that everything is stored as string on protocol level)
  • Java implementations automatically map it to java.util.Date
  • Typescript implementations automatically map it to something sensible in Typescript

(This typedef might be shipped with LIonWeb standard library.)

Some thoughts on this design include:

  • date/time is hugely complex
  • there are sensible implementations in most languages, we don't want to re-invent the wheel and integrate nicely with host languages

@enikao
Copy link
Contributor Author

enikao commented Jan 22, 2023

@joswarmer Are your questions answered? Then I'd close.

@joswarmer
Copy link
Contributor

Ok, I understand. You can close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants