Serialize JSON opennurbs question

After I tried to serialize some geometry to JSON and unit tested it some while ago, now I see that the opennurbs value changed. Could you please tell me what the number value for opennurbs means? It looks like this:

“Geometry”:{“version”:10000,“archive3dm”:70,“opennurbs”:-1910736147,“data”:"+n8CAM4AAAAAAAAA+/8CABQAAAAAAAAAGRGvXlEL1BG//gAQgwEi8EoaeRf8

And the question would be: what could cause the change of this number.
Any insights would help a lot :slight_smile:

@stevebaer Hi! I think you will know the answer, or at least know the guy who might know it :slight_smile:

It looks like something is counting there from the minimum integer value up to maximum.

Value changed when I moved project from one PC to another, and upgraded .NET in the project, so I guess the reason could be one of them.

Hi @w.radaczynski

I think unit testing the actual contents of the string is not a correct test, because as you can see you are not certain about what the result should be (assertion step) Instead you can always test whether the serialized rhino object is not a null or empty string. In addition, you can then do the opposite test, then you have two unit tests which handle any of the given situations. This means that your production code will do so as well.

Anyways, for informational purposes your question to Steve is also very pertinent.

Hi @rawitscher-torres :slight_smile:

at first I need to mention, that I don’t test the serializing part. I test some objects by serializing them instead. You might ask me then why I do it like that, if I can test the properties instead for example.
Well the thing is, that sometimes I have cases like this:

I have an object and I call some method that is using it, and I want to make sure, that this method didn’t changed anything in the object used. Default way would be to for example check every single property and make sure that nothing changed. But then you will have a lot of asserts, to make sure that it is like that. So my way is to serialize this object before the method is being called, call the method, serialize object once again, and compare two result strings. It takes 3 lines of code, and I am sure that nothing have changed.

Testing if Rhino object is null or empty doesn’t make sense, as it only tests if you got any string. When I test Rhino geometry objects, then assertion of true with GeometryEquals does the job, but we’re not talking about the geometry comparisons or making sure if Json serialize function succeed, but about the opennurbs value mystery, that was found by accident during running the tests :slight_smile:

1 Like

The opennurbs value is the exact version of opennurbs used to write the geometry. This value changes with every service release of Rhino.

1 Like

Thank you! :slight_smile: