Arrays are converted to objects
See original GitHub issueDescribe 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
- Create a new source JSON file containing an array
- 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:
- Created 2 years ago
- Comments:14 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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!