TheOpenCloudEngine / uEngine5-base

uEngine5 BPMS that totally re-written in Microservices architecture. uEngine5 can act as not only a conventional Workflow or BPMS but also as a REST api orchestrator or a BPaaS (Business process as a service) of members of OCE's MSA components.
MIT License
10 stars 13 forks source link

Typed JSON 에서의 Unexpected token (START_OBJECT), expected VALUE_STRING: need JSON String that contains type id #114

Open jinyoung opened 6 years ago

jinyoung commented 6 years ago

In terms of using Typed JSON, sometimes this kind of serialization error usually occurs:

Unexpected token (START_OBJECT), expected VALUE_STRING: need JSON String that contains type id(java.util.List)

This occurs when then generic type of List is an abstract class, we should provide the prototype of the json data like:

-case1:

Java:

    ArrayList<AbstractActivity> childActivities;

Javascript JSON should be:

          childActivities: [
            "java.util.ArrayList",
            []
          ]

But the case that the generic type is not an abstract class or final class, the JSON should be regular array:

in Java:

    ArrayList<DefaultActivity> childActivities;

Javascript JSON should be:

          childActivities: [
          ]

Actual example in uEngine model:

SubProcess.vue

      createNew(newTracingTag, x, y, width, height){
        return {
          _type: this.className(),
          name: {
            text: ''
          },
          tracingTag: newTracingTag,
          selected: false,
          childActivities: [
            "java.util.ArrayList",
            []
          ],
          sequenceFlows: [], // arrayList of sequence flows has its generic type SequenceFlow that is not an abstract class
          variableBindings: [
            "java.util.ArrayList",
            []
          ],
          elementView: {
            '_type': 'org.uengine.kernel.view.DefaultActivityView',
            'id': newTracingTag,
            'x': x,
            'y': y,
            'width': width,
            'height': height,
            'style': JSON.stringify({})
          }
        }
      }