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.

Arrays are converted to objects

See original GitHub issue

Describe the bug Currently when translating JSON files from source to target, it converts any arrays inside the source JSON files to object representations of such like so from:

"address": {
    "lines": [
        "Line 1",
        "Line 2",
        "Line 3"
    ]
},

to

"address": {
  "lines": {
    "0": "Line 1",
    "1": "Line 2",
    "2": "Line 3"
  }
},

To Reproduce

  1. Create a new source JSON file containing an array
  2. Convert the JSON file to another language

Expected behavior The expected behavior would be that the datatype stays the same.

Files This could be done using any simple JSON file containing the above example content.

Additional context N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
fkirccommented, Jan 24, 2022

I agree with your conclusions, we should probably replace the entire nested-json implementation with a recursive implementation, similar to the recursive YAML-implementation which is already working well.

The original intention behind the flat translation map was to (1.) provide a unified interface for all file-formats and (2.) enable cross-format-translations. I think that this interface is still working because the individual file-formats are free to cache the entire source-file. In other words, the source-JSON-file can remain in memory for a recursive string-replacement-procedure.

0reactions
dwknipperscommented, Jan 25, 2022

Hey thanks so much, seems to be a much more robust implementation! 🌟 Sorry I couldn’t spend much time on this, but the PR is solid work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to convert an Object {} to an Array [] of key-value pairs in ...
Object.entries() returns an array whose elements are arrays corresponding to the enumerable property [key, value] pairs found directly upon object .
Read more >
Converting Object to an Array | SamanthaMing.com
We have 3 variations to convert an Object to an Array. Array has an array of methods (sorry, bad pun ). So by...
Read more >
Convert an Object to an Array in JavaScript
To convert an object to an array you use one of three methods: Object.keys() , Object.values() , and Object.entries() . Note that the...
Read more >
Convert object to array in Javascript - javatpoint
Let's look at the different ways of converting objects to arrays in javascript. To convert an object into an array in Javascript, you...
Read more >
Convert an Object to an Array in JavaScript - Scaler Topics
An earlier approach to converting an object to array javascript was lengthy, to make it short and easy, ES6 introduces the Object.keys method....
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