Question: I want to grab some data from lucene index file. But I can't read it.

I try to use `Luke`, but it always crashes with `java.lang.OutOfMemoryError: Java heap space`. Note `-Xmx` can't help me. I try -Xmx512, -Xmx1024 and even -Xmx2048.

I try to use `Solr` also, but gets `java.lang.OutOfMemoryError: Java heap space` too.

Any ideas how I can extract some data from Lucene?

P. S. I use lucene 2.3.0. My index file is 1.8 Gb size.

Answer: 
If your array uses a `string` key value, instead of an `int`, stringify ignores that value.

```
var array = [];
array['name'] = 'johan';
array['age'] = 20;
alert(JSON.stringify(array))// return []

```

But if array uses an "int" as a key, then `stringify` will return it.

```
var array = [];
array[0] = 'johan';
array[1] = 20;
alert(JSON.stringify(array))// return["johan",20]

```
While the answers above are true, to fully understand it definitely needs more context.

JSON is an universal format (in the sense of supporting multiple, hopefully all programming languages) that is not entirely a 1-to-1 mapping of JavaScript objects.

So the root reason for why this happens is that in JSON (as specified by [RFC 7159](https://www.rfc-editor.org/rfc/rfc7159)) there are no associative arrays in the JavaScript's `Array` sense -- i.e. arrays whose keys are strings. As reading RFC specs can be rather time-consuming, it can be most easily seen on top of the [JSON.org](http://json.org) website where it says (*some of emphasis below is mine*):

> 
> JSON is built on two structures:
> 
> 
> * A collection of name/value pairs. In various languages, this is realized as an *object*, *record*, *struct*, *dictionary*, *hash table*, *keyed list*, or ***associative array***.
> * An *ordered list* of values. In most languages, this is realized as an ***array***, *vector*, *list*, or *sequence*.
> 
> 
> These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.
> 
> 
> In JSON, they take on these forms:
> 
> 
> An *object* is an ***unordered*** set of name/value pairs. An object begins with `{` (left brace) and ends with `}` (right brace). Each name is followed by `:` (colon) and the name/value pairs are separated by `,` (comma).
> 
> 
> ![JSON Object definition graph](https://i.stack.imgur.com/KoNQc.gif)
> 
> 
> An array is an ordered collection of values. An array begins with `[` (left bracket) and ends with `]` (right bracket). Values are separated by `,` (comma).
> 
> 
> ![JSON Array definition graph](https://i.stack.imgur.com/h3las.gif)
> 
> 
> 

The `JSON.stringify` function handles this in such way that assuming that array is intended to be an array, and all keyed entries are annotative, so much like elements that are function objects, they are just thrown out of the JSON representation it returns. Unfortunately this behaviour is not documented in a well defined and easily understandable way in the unofficial JavaScript reference that is [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) as of today (2017-09-04) so here is some low-hanging fruit if you want to help the ol' Mozilla.