Defining JSON property types in GraphStudio

Is there a way that I’m missing to define a JSONArray or JSONObject property in GraphStudio?

1 Like

With the version 3.0 you can:

You can also check our GSQL documentation:
https://docs.tigergraph.com/dev/gsql-ref/ddl-and-loading/system-and-language-basics#attribute-data-types

Best,
Bruno

Thanks … so a very dumb, clearly beginner question to follow up. If I want to have a JSONARRAY property on a vertex, do I define the property as a STRING and then just know that I’m storing a JSONARRAY there and so use the JSON related functions on that property in a query? Is that how it works? I tried in gsql defining a property of type JSONARRAY which didn’t work hence my novice question.

1 Like

The question would be how you are going to consume the data in the Array?
If you need to proccess (filter / search on) it, then the fields in the Array should be splitted and inserted as attributes. If you just need to present the Array when you get the result, then you can use it in a String, since it would be just read and not processed.

OK, thanks … I’ll have to think about that … the issue is that the property would have an array of, for example, email addresses in a complex type. More reasonably modeled as a vertex with a defined edge but the responsible team doesn’t want things modeled that way. They will want to be able to query to see if the array contains a particular email address in the array of addresses.

maybe you should think about a vertex with emails and an edge to corresponding vertex - splitting the array into single records would be the way to go.

Yes, that is, I think what I said would be best … they want to embed the arbitrarily long list of email addresses (and another similar for postal addresses and yet another for phone numbers) in the vertex. In any case, to my original question … in order to set a property that is a JSONARRAY, given that I can’t define that as a property type directly, is the way it is done defining something as a string and then “knowing” that it isn’t strongly typed to a JSONARRAY or JSONOBJECT?

In this case you can use STRING. Attribute name could be named with the hint of the data type i.e. email_jsonarray

Thanks … are there any outstanding feature requests to promote these to 1st class properties?

Hi @Padishah

outstanding feature requests to promote these to 1st class properties?

Let me check with @VictorLee regarding this :point_up:

It is not on our current roadmap to support JSONARRAY or JSONOBJECT as attribute data types. You no doubt saw in our query language documentation that we have support for JSONARRAY and JSONOBJECT in the query language. https://docs.tigergraph.com/dev/gsql-ref/querying/operators-functions-and-expressions#jsonobject-and-jsonarray-functions

The query language has functions to convert a string to JSONOBJECT or JSONARRAY, and then it has some functions for extracting data from those objects.

Do you work with a lot of JSON data which needs to remain in JSON format, or can it be parsed during data loading into its constituent elements and relationships?

Yes, we have a number of use cases where the input is JSON and is not easily decomposed into individual properties and where the teams are not interested in modeling things as vertices with edges.

Also, just in general, our requirements are to clearly document our data and overloading “STRING” types that are really JSON furthers the need for tribal knowledge for others to view/consume these properties. So, clear property definitions that represent the underlying type is highly desirable.

2 Likes