It's not as general purpose, but would regular expressions work for your
use case?

Here's a string that's 280,000 characters and parses in 4.5 seconds with
regex

ts=: 6!:2, 7!:2@]


json=: 0 : 0

{

"abc":123,

"xyz":"foo"

},

)


blob=. , L:0 (10000, # json) $ json


parse=:3 : 0

abc=: 1}"1 ('"abc":(\w+)' rxmatches blob) rxfrom y

xyz=: 1}"1 ('"xyz":"(\w+)"' rxmatches blob) rxfrom y

)


ts 'parse blob'


4.42068 8.04301e6


I only ask because often I work with JSON that has a fixed/flat format and
don't need the entire structure. You mentioned six levels deep so it may be
more complex than its worth.


JSON.parse(json) in chrome parses it instantly when I test from the
console, so there is definitely an opportunity to speed it up


On Tue, Oct 15, 2013 at 1:01 PM, Raul Miller <[email protected]> wrote:

> Oh, great, on this mac, the key sequence I use to paste text will also
> in at least one context send the message.
>
> Anyways, picking up where I left off:
>
> On Tue, Oct 15, 2013 at 12:55 PM, Raul Miller <[email protected]>
> wrote:
> > I just now used the json parsing code at
> > http://rosettacode.org/wiki/JSON#J on a moderately sized json string
> > (219003 characters).
> >
> > Here's what space and time look like for this effort:
>
> 16.1096 5.26771e6
>
> That seems excessively slow. I think the speed loss has to do with the
> way boxing is managed. The result has a depth of six.
>
> I've seen similar performance problems when I've tried to use J
> parsing other data from foreign contexts. (For example, parsing
> bethesda games .nif files.)
>
> I've considered other representations (like using locales as objects
> to represent what I'm using a box to represent), but that winds up
> with object counts in the millions, and the manual memory management
> required with locales makes this approach scary. I might as well be
> working in some other language, for all that J offers me here.
>
> But Arthur Whitney's K/Q has a tree structure that is almost like J's
> boxing mechanism and allegedly it has good performance.  And then
> there's https://github.com/kevinlawler/kona
>
> So I'm wondering if perhaps we could improve J's implementation here?
>
> But I'm not focussed enough on this issue to say how that would work.
>
> Thanks,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to