question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

long pending JS to JSON conversion issue - nested arrays become maps

See original GitHub issue

a very annoying issue that has been around since the beginning, but fortunately only affects a relatively rare case when JSON is constructed on the JavaScript side (typically in an eval or JS function) and where there are nested arrays, they become JSON with keys like 0, 1, 2, etc. just figured out a possible fix. opening this issue to track, and this could be a breaking change for some teams

details: https://stackoverflow.com/a/54256766/143475

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tellisnz-shiftcommented, Jun 1, 2019

The commit 38ad211 seems to break java interop for us, but maybe we’re doing something incorrectly so let me know. It goes like this:

In our karate-config.js, we add a reference to a Java type (which is actually a Kotlin object) that has a function we want to call in our scenarios, e.g. karate-config.js

function fn() {
  var config = {};
  // INSTANCE is a reference to a singleton instance of the kotlin object
  config.testDataSetup = Java.type('com.example.TestDataSetup').INSTANCE;
  return config;
}

Then in our scenario:

* def testUser = testDataSetup.createTestUserInDb()

I’ve built the commit preceding 38ad211 and it works fine, but when using a build of 38ad211 we get javascript evaluation failed: testDataSetup.createTestUserInDb is not a function in <eval> at line number 1

I’ll have a bit of a debug with the changes in 38ad211 but also maybe you know off the bat what’s wrong?

1reaction
tellisnz-shiftcommented, Jun 2, 2019

👍 looks good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

long pending JS to JSON conversion issue - nested ... - GitHub
a very annoying issue that has been around since the beginning, but fortunately only affects a relatively rare case when JSON is constructed ......
Read more >
Convert JSON array with nested arrays (tree) to flat JSON array
The code works well, but I would like to get rid of the extra steps to create a list with the names using...
Read more >
Resolving Nested Promise Arrays - Pat Migliaccio
Resolving data from separate resources in JavaScript may lead to a bit of asynchronous complexity when working with nested Promise arrays.
Read more >
How to Run an Asynchronous Function in Array.map()
Array.map() is a synchronous operation and runs a function on each element in the array resulting in a new array with the updated...
Read more >
JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON ... longer than that) is inserted before every nested object or array.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found