0

Shotgun REST API and JSON decoding question

I am moving our custom desktop (C#/WPF) Shotgun tools to the new Shotgun REST API and I have some questions:

 

  1. I am using var lEntity = JsonConvert.DeserializeObject<MyShotgunEntity>(lPayload) to convert the JSON payload into a C#.
  2. I then put the lEntity through a translation layer (DTO) to convert it to my application Model representation of the data.
  3. I am generating a unique class MyShotgunEntity for each Shotgun entity in my schema.
  4. I do this manually by retrieving a single entity of each type and creating a C# class for it using VisualStudio -> Edit -> Paste Special -> Paste JSON As Classes
  5. This works, but there are a number of issues with the processes:
    1. It is labour intensive.
    2. The classes generated are cluttered and need manual cleaning.
    3. The classes generated are dependent on the data in retrieve entity blob.
    4. The returned fields don’t always *appear* to be the correct type
  1. Some are string, int, bool etc.
  2. Some are objects (when they are string, int, bool etc)
  • In the schema we currently use some of them are string?, int? bool? (nullable)
  1. So, do you have a better mechanism for easily (!?) getting a C# class that maps the JSON schema of entities within a Shogun database instance.

 

I think that covers all the current JSON / Schema issues

 

Now on to a couple of REST questions. I’m new to REST so please bear with me.

 

Here is an example of a body for a _search request

{

                "filters": [ [ "project", "is", { "type": "Project", "id" : 143 } ] ],

                "fields":["code", "description", "sg_status_list", "project"]

}

 

It filters all the requested entities for those with a project reference to Project.id 143

I am trying to work out how make the same call with an array of ids. i.e. [143, 156, 192, 200]

That is, do the same search, but for all entities with a reference to “one of these projects” (with the id in array)

Is this possible or do I need to add as many filters as there are items in the array?

 

I will be writing more complex filters where there may be multiple fields having such searches, so any help would be greatly appreciated.

 

 

 

1件のコメント

  • 0
    Avatar
    James Thomas

    Thank you!!

     

ログインしてコメントを残してください。