-
Notifications
You must be signed in to change notification settings - Fork 266
Human readable serialization
The goal is to output something that is easier to read than JSON. Something along the lines of NomDL but for values.
- Machine readable
- This implies that nothing can be ambiguous. We can solve this by knowing the type.
- Human readable
- No numeric enum values.
- No extra quotes.
- No extra
[]
. We can define our own syntax for set and map. Optionally hide typeShort hashes- Indent output
Partial lists/strings/blobs/collections. When a list gets too large we could write...
We probably need a --depth
flag to follow refs.
Background can be found in. https://github.com/attic-labs/noms/issues/1153. However, this uses JSON which is not what we want.
The encoding of this is always UTF-8.
Numbers are using exact representation when possible. We allow -
/+
and e
/E
.
Strings are double quoted and "
and \n
are escaped. TBD what else is escaped.
true
or false
base64 encoded
The main issue is how to represent an empty blob?
[
value (,
value)* ,
? ]
{
value (,
value)* ,
? }
{
value :
value (,
value :
value)* ,
? }
sha1-12345
We'll probably have a flag to output full vs abbreviated hashes
StructName {
name :
value (,
name :
value)* ,
? }
All but Struct are just using the tag... Number
, List<String>
etc.
struct Color {
red: Number,
green: Number,
blue: Number,
opacity: Number,
}
Not valid. A concrete value cannot have the type Value.
When the type is not known from the context we need to tag the Value
. This is done as
T(V)
.
No need to tag it. The syntax is unique.
Tagged by Blob
.
Blob(TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvb)
Tagged by List
.
List<Number>([0, 1])
One option would be to omit the parens here but I left them for consistency.
Tagged by Set
.
Set<String>({"a", "b"})
Tagged by Map
.
Map<Number, String>({97: "a", 98: "b"})
Tagged by Ref
.
Ref<Number>(sha1-3123419)
Tagged by Struct
.
struct Person {
name: String,
age: Number,
}({
name: "John Smith",
age: 45,
})
Tagged by Type
Type(Number)
Type(List<Bool>>)