Serializer (VL)

I can never get anything meaningful from the serialisation nodes. Could anyone post a simple example for creating and extracting serial data from these nodes?

i’ve tested it with alpha d1292f6cc3 and it seems to work with a simple double value… it had a little initialization hickup though.

if you are trying to serialize more complex data please provide a patch which shows the problem.

Thank Tonfilm, I’m just trying it out as I learn but I dont understand how I could say group data sets and tag them.

What exactly do you mean by “group and tag them”?

Say I were trying to serialize a set of data like this:

{
{
“$schema”: “http://json-schema.org/schema#”,
“title”: “Product”,
“type”: “object”,
“required”: [“id”, “name”, “price”](“id”, “name”, “price”),
“properties”: {
“id”: {
“type”: “number”,
“description”: “Product identifier”
},
“name”: {
“type”: “string”,
“description”: “Name of the product”
},
“price”: {
“type”: “number”,
“minimum”: 0
},
“tags”: {
“type”: “array”,
“items”: {
“type”: “string”
}
},
“stock”: {
“type”: “object”,
“properties”: {
“warehouse”: {
“type”: “number”
},
“retail”: {
“type”: “number”
}
}
}
}

This won’t ‘deserialize’ at all at the moment, but if it did, how would it be structured? The same question is applicable serialising any small data set and trying to setup types and properies along specific values. Source

the serializer can take data and serialize it. thats all… you cant influence how it does that. except that you can choose the underlying file format.

it will deserialize into .NET data types. the json in your example seems to have javascipt style class structure which cannot be interpreted by .NET.

however, you can achieve a similar looking json by creating data types like product, article, price and stock. then you have to build an object structure with them and pass the root object to the serializer. this should result in a similar file content. this can then also be dserialized into the same object structure.

@elias can explan in more detail whats possible and what not.
also check the serializer website for more information: http://nessos.github.io/FsPickler/index.html

hey guest,

the json you posted is not valid. you can use any online parser to see, if a json can actually be deserialized.

{
  "$schema": "http://json-schema.org/schema#",
  "title": "Product",
  "type": "object",
  "required":["id", "name", "price"]("id", "name", "price"),
  "properties": {
    "id": {
      "type": "number",
      "description": "Product identifier"
    },
    "name": {
      "type": "string",
      "description": "Name of the product"
    },
    "price": {
      "type": "number",
      "minimum": 0
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "stock": {
      "type": "object",
      "properties": {
        "warehouse": {
          "type": "number"
        },
        "retail": {
          "type": "number"
        }
      }
    }
}
}

just ran it through vvvv-Message, and it parses beautifully.

The serialization nodes as they’re right now in VL can only be used for “static” cases. With static I mean that it is known at compile time how your data looks like and should you decide to write the serialized data to disk that on de-serialization some point later (weeks for example) your data types still look the same.
In other words the deserialization will fail if either

  • your data type changed (fields got added or removed) or
  • the data type itself if not known to the system.

For both of these cases we’ll have to find a solution. Case one is more tricky as it usually needs some kind of converter functions one needs to apply based on the version saved on disk.
Case two can be solved by using “dynamic” data types - like for example velocrome’s Message class or objects in JavaScript. Dynamic types are usually implemented by using a list of key-value pairs internally. In VL we don’t provide such a dynamic type yet. Certainly something to look into. @velcrome could probably enlighten us more on this topic.

Elias, Velcrome and Tonfilm thank you al for your input and I’ve looked at the data structure patch from the vl Girlpower. As Ton mentions, in the case of static types as found in the patch I can see how useful it is internally, but I hope you find a solution for dynamic types, or that a library pops up with the answers.

The DataStructure Girlpower is broken. Could you add example of deserialization too please?

Danke

sorry, for the delay.
girlpower\VL_Basics\DataStructure
is now fixed and has a deserializer added…