Skip to content

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

@jinyoung

Description

@jinyoung

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({})
          }
        }
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions