fairDataSociety / beeson

blockchain-verifiable, extensible encapsulation for schema-based object notation in Swarm
5 stars 3 forks source link

Update Readme #11

Open tfius opened 2 years ago

tfius commented 2 years ago

When constructing new BeeSon object from JavaScript keep in mind that due to

interface JsonParams<T extends JsonValue> { json: T; }

creation of BeeSon object requires that input variable is named json or else constructor will fail and return Invalid BeeSon constructor parameters

to recap: let data = { name: 'john coke', age: 48, id: 'ID2' } let json = { name: 'john coke', age: 48, id: 'ID2' }

const beeson1 = new BeeSon({ data }) will NOT work const beeson2 = new BeeSon({ json }) will work

nugaon commented 2 years ago

it is not required to name the variable as json, it is one property of first parameter of the constructor. you can init BeeSon with data in the following way: const beeson1 = new BeeSon({ json: data }) or you can even init BeeSon object with a TypeManager object: new BeeSon({ typeManager }) - in which case you can use any variablenames for defining typeManager as well.

crtahlin commented 2 years ago

Is this clear from the readme docs, or should sth be added, maybe example? Otherwise issue close, please.