Hi Sundar, Thank you for the answer. I have filed a RFE #9053373, with the minimal intrusion in the API which already should allow people to work with Nashorn more comfortably.
/Victor --- Original message --- From: "Sundararajan Athijegannathan" <sundararajan.athijegannat...@oracle.com> Date: 13 April 2018, 05:47:38 > Please note that a general Java object graph may involve circular > references. Without modifying JSON somehow, it is not possible to handle > such cases. That said, please do file a rfe with your ideas and we can > discuss. > > -Sundar > > On 11/04/18, 10:18 AM, Victor Polischuk wrote: > > Dear all, > > > > I apologize if the question was already raised in the mail list, however, I > > find it quite strange that JSObject lacks convenient methods to convert it > > at least to JSON-string, if not directly to Java-POJOs? > > > > The Internet is full of suggestions which involve JavaScript > > JSON.stringify(..) as a utility. While it might work too, but I guess a lot > > of others are just traversing the JSObject by their own "converters". > > > > Therefore, if there is no design limitations/reasons why the conversion > > should/could not be applied within the Java representation, I am ready to > > volunteer on the patch. > > > > My reason for it are: > > * It looks quite ugly to execute JavaScript to make something with "almost" > > Java object. > > * Java has enormous number of JSON libraries already. I guess it is nice to > > allow people connect their favorite with minimal efforts. Potentially, if > > it will be required "string" phase might be excluded (not > > JSObject->String->POJO, but JSObject->POJO). > > * It may simplify logging/debugging of interaction between Java and JS. > > > > / > > Best Regards, > > Victor >