Skip to content

[Typescript] The createXXXFromString assumes valid json #25

Description

@krissrex

Description: I am trying to deserialize xmi. One of the EDataTypes I created (ActionId) has a value "ecore:new_child".
When the code tries to create this ActionId, it runs this:

public createActionIdFromString(eDataType:EDataType, initialValue:string):string {
  return initialValue == null ? null : JSON.parse(initialValue);
}	

This assumes the initialValue (which is ecore:new_child) is valid json, and it crashes:
image

It gets there via XmiResource.addEStructuralFeatures (line 169):
var literalvalue = _this.factory.createFromString(etype, value);
then via my Factory's public createFromString(eDataType:EDataType, initialValue:string) to the snipped shown first.


It would work if my initialvalue was wrapped in quotes: "ecore:new_child".
But this EDataType was not stringified by the crossecore library, but the Eclipse IDE editor for xmi.

This is an excerpt of the xmi:

<availableActions
          id="ecore:new_child"
          name="New child"/>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions