JsonData Package

datastructure
developers
package

#1

Hi all!

I just want to share with you the JsonData package, which I have been developing every now and then and I find very useful on my workflows.

JsonData is a set of custom nodes to handle data using json-like structures. There is more info on the GitHub Wiki, but in essence it is based on the use of Dictionaries and displaying them as json structures.

Besides the basic methods to create, get values or add/remove keys, the package also includes nodes like merge, filter by values of a given key or sort them by values.

There are also two key capabilities built in the objects:

  • JsonOptions to determine how to handle duplicated keys:
    • None: Default value, which throws an exception.
    • Update: Which updates the value for the already existing key.
    • Combine: Creates a JsonArray object and combines both values
  • ‎Easy creation of nested structures by providing keys concatenated by dots (nesting is true by default).

Finally, it also comes with utilities to parse, read and write from/to json, XML and CSV, which covers most of the key data sharing formats. In this example I used Read.FromXMLFile to parse and query a .dyn file for a particular python script, and run it from another file.

Hopefully you´ll find it as useful as I do. It might be a small contribution to the Dynamo community, but it is exactly the essence of Dynamo, any bit counts! Besides, it has been quite fun to develop :slight_smile:


Excel Data into Revit
Graphical Package
Filter List by Element that is in a List of this List
#2

Awesome cheers


#3

This is an awesome share - I see tons of potential with this.

Also glad to hear it was fun. Sitting back and watching the use cases will hopefully provide even more enjoyment! :smile:

I’m off to test the limits and see what I can parse from my code blocks - perhaps every custom function built in my dyn library? :crossed_fingers:


#4

Hi @alvpickmans,

Dynamo developer here.

This is super powerful. Have you taken a look at the new Dictionary feature incoming for Dynamo 2.0? I think it might work pretty nicely with what you’ve done here. For example, in Dynamo 2.0, you can initialize a Dictionary just like JSON:

dict = { "foo" : [1,2, { "bar": Point.ByCoordinates() }] };

There is also a collection of nodes, such as Dictionary.ByKeysValues. We’ve considered adding additional nodes, like JSON.Parse, and JSON.Stringify - which would produce and consume Dictionary’s. Let me know what you think.


#5

Hi @pboyer ,

I did check the new dictionaries and is an awesome step! They are actually the reason I wanted to wrap up everything I have been doing over the past year with JsonData before it goes to the oblivion :slightly_smiling_face:

I think it would work well with dictionaries and I would love to contribute for Dynamo 2.0 if there’s still time before its release. Do you have a date scheduled?


#6

Hola amigos,

Just wanted to post that I have upgraded JsonData to Dynamo 2.0 (finally, my laptop died horribly)! While doing so, I have also fixed a few things, remove a few others and streamlined its use :slight_smile:

Changes are not too many, for a better description please check the change log here. Two key things I would like to point out:

  • Dynamo dictionaries are now supported by the addition of two nodes to create JsonObjects from dictionaries and viceversa.

  • Nodes requiering JsonOption and/or nesting behaviour are now improved by removing these inputs and embeding them into the nodes UI, so less need of extra nodes on the graph!

Cheers,
Al


#7

Hey,

I’ve just started using your package, but am having trouble with the Write.ToJsonFile node.

The error reads:

Warning: Write.ToJsonFile operation failed.
File extension is not of System.Collections.Generic.List1[System.String] type. Please select a valid System.Collections.Generic.List1[System.String] file.

Would appreciate if anyone could point me in the right direction.

Thanks.


#8

Could you show what are you feeding to the filepath input?:slight_smile:


#9

Hey,

I actually figured it out. There was an issue with the file path and actual JSON file generation.


#10

Glad to hear that :slight_smile:


#11

Hi Al, thanks for this useful package!

I found an issue using it.
Every time I close the Dynamo file and open it, JsonObject.GetValueByKey node mutate from its normal shape to this one:
image

Dynamo Core 2.0.1.5055
Dynamo Revit 2.0.1.5065
JsonData version is 2.0.1.

I’m wondering why it might happen. Never seen it happening with other nodes before.

Thanks and regards,
Valentin.


#12

this happens if this node has not been updated to dynamo 2.x yet. It needs a JsonConstructor attribute added.


#13

Check to make sure you are using the latest package version.


#14

I think it was updated but will check today anyway! Thanks for the feedback!


#15

Ok, I just checked and I cannot replicate the issue. As @Michael_Kirschner2 mentions, that error happens for the lack of JsonConstructor attribute but that’s there.

Could you check if there is any Newtonsoft.Json.dll file in the bin directory on the package’s folder? It shouldn’t be any, but just to double check.

If not, please try to delete the package and download the latest version.


#16

You may also want to check if something else is loading another version of json.net… like another addin loading version 10 or 11. Revit itself delivers 9.0.1 I believe and we deliver 8.0.3 - we have found them to be compatible. I think newer versions can cause issues if also loaded so I would first try removing addins as a debug step.


#17

The duplication seems to still be happening in 2.02 with the json object by key and values node as well. Each time I save and reopen the node adds another set of key and value inputs and a jsonOpject out. Just installed with Json Data 2.0.1.


#18

I cannot replicate the issue. I can only think that there must be a different version of Newtonsoft.Json.dll being loaded from another package/source and that’s messing with the inputs…

Can you try and search any Newtonsoft.Json.dll file on your packages folder, and if any its version? Also, is this happening only in Dynamo Revit or Sandbox too?


#19

So it continues… I am in Dynamo Revit -2.02. There were 2 other Newtonsoft.Json.dll’s. 1 in Lunchbox version 7.0.1.18622 and 1 in Dynaweb version 10.0.2.20802.

I moved the entire Lunchbox folder out of the packages directory.
and replaced the Newtonsoft.Json in the Dynaweb package with a newer version - 12.0.1…and the replication continued.

I moved all the custom packages except for JsonData from the package directory and the duplication continues. So I would guess its something about the machine.


#20

try removing both lunchbox and dynaWeb. Have they both been updated for dynamo 2.0?