[
https://issues.apache.org/jira/browse/TINKERPOP-2497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17253561#comment-17253561
]
Ben Smith commented on TINKERPOP-2497:
--------------------------------------
Of that I am not certain.
I am able to get the proper output when I use a wrapper around the response
from above and before JSON.stringify.
{code:java}
const runTest=async ()=>{
const map= await g.V().has('name','ben').elementMap().toList()
console.log(JSON.stringify(mapToObj(map)))
}
const normalizeData= (gremlinData)=> {
// Do this so that JSON.stringify works for maps
(Map.prototype).toJSON = function () {
return Object.fromEntries(this);
};
const mapStrippedData = JSON.parse(JSON.stringify(gremlinData));
// Undo it so that we don't permanently pollute globals
(Map.prototype).toJSON = undefined;
return mapStrippedData;
}
{code}
However, this requires a combination of parse and stringify which seems like it
would be slow on large lists.
I would assume the gremlin javascript would handle this as it might be faster
than in application or on the client.
> Gremlin JS Serializer always empty [{}] with valueMap(), entitypMap()
> ---------------------------------------------------------------------
>
> Key: TINKERPOP-2497
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2497
> Project: TinkerPop
> Issue Type: Bug
> Components: javascript
> Affects Versions: 3.4.9
> Reporter: Ben Smith
> Priority: Minor
>
> Sorry if I made this ticket incorrectly.
>
> I've installed gremlin as indicated.
> Running such a call as
> g.V(id).elementMap().toList(); fails to return from my client application
> output results is always [{}]
> same with return g.V(id).valueMap().toList();
> The above calls can output to the console correctly but not be serialized.
> Other toList calls work when the type is Vector. but seem to fail with Map.
> I am running Express, against Tinkertop 3.4.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)