Skip to content

Print without serializationΒ #58

@FGRibreau

Description

@FGRibreau

Hello πŸ‘‹

First thing first, sorry for this dummy question,

I have this transit string:

{"~:user/email":"plop@plop.com","~:user/uid":"OXeehCUcSCaglURUsQ","~:block/uid":"uqJ"}

that I would like to convert to:

[":user/email", "plop@plop.com", ":user/uid", "OXeehCUcSCaglURUsQ", ":block/uid", "uqJ"]

I've tried:

function mapToObj(transitMap) {
  // object with "~:xxx/xxx" keys:
  return mapKeys(writer.write(transitMap, { marshalTop: false }), (val, k) => k.replace(/^~:/, '')); // :O 
}

const convert = pipe(mapToObj, toPairs, flatten);

// usage:
convert(deserializedTransitString) => [..., ... ,...]

I've read most of the code of transit-js but could not find an easy way (beside relying a transform mapper when calling writer.write) to do this. Is this the only way or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions