flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Zarzycki (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLEX-35297) JSON.stringify is not working with object marked by Bindable
Date Wed, 19 Apr 2017 21:36:41 GMT
Piotr Zarzycki created FLEX-35297:

             Summary: JSON.stringify is not working with object marked by Bindable
                 Key: FLEX-35297
                 URL: https://issues.apache.org/jira/browse/FLEX-35297
             Project: Apache Flex
          Issue Type: Bug
          Components: FlexJS
    Affects Versions: Apache FlexJS 0.8.0, Apache FalconJX 0.8.0
            Reporter: Piotr Zarzycki
            Assignee: Greg Dove

FlexJS is using JSON.stringify to produce json from value objects. 
Two general issues has been discovered during development:

1) "stringify" function is not able to parse object which is marked by [Bindable] tag

In the attached example there is class Book which is marked by [Bindable] tag. During parsing
we are getting stack trace:

Uncaught TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)

This happened cause compiled VO object contains additional properties which "stringify" is
not able to parse. (book_js_with_bindable.png)
2) there are differences between swf and js sight in results of parsing by "stringify" function

*JSON.stringify SWF:* 
    "date":"Wed Apr 19 14:00:50 GMT-0500 2017",

*JSON.stringify JS:* 

*Expected results:*
1) We should be able to parse object with [Bindable] tag without any issues
2) SWF and JS stringify function should produce exact same json results.

- In order to avoid issues above VO should contains "toJSON" function.

Example class with toJSON function:
public class Book
        public var title:String;
        public var page:int;
        public var date:Date;
        public var authors:Array;
        public var topic:Topic = new Topic();

        public var doNotHide:uint = 99;
        private var internalDate: Date = new Date();

		private var _dedication:String;

        public function get dedication():String
            return _dedication;

        public function set dedication(value:String):void
            _dedication = value;

		public function toJSON():Object
			return {title: title,
				page: page,
				date: date,
				authors: authors,
				topic: {name: topic.name},
				doNotHide: doNotHide,
				internalDate: internalDate,
			    dedication: dedication};

This message was sent by Atlassian JIRA

View raw message