Hi

I have a json file something like this...

{"title": ["stuff"], "body": ["stuff"], "other": ["stuff"]}
{"title": ["stuff"], "body": ["stuff"], "other": ["stuff"]}
{"title": ["stuff"], "body": ["stuff"], "other": ["stuff"]}

I'm new to json and I've been testing out paths using this online helper http://michaelfarmer.info/jsonpath/

Once I've created my importer and then visiting the /import form, I'm asked to enter the context and the jsonpaths to run.

Where it says "This is the base query, all other queries will run in this context." I entered "$.*" (without the quotes)
Where it says "The JSONPath expression to run." I've tried "$.body", ".body", and "body"

I can't seem to work out what the correct input should be.
Can someone please advise?

Much appreciated,
cheers
scotjam

Comments

scotjam’s picture

My mistake!
I'm using a variation of json format called json lines.

Oops!

Don't suppose its possible to parse this format with some code changes, is it?

p.s. please feel free to close at any time.

cheers
scotjam

twistor’s picture

I did some searching and couldn't find any documentation for the format except for http://doc.scrapy.org/topics/exporters.html#scrapy.contrib.exporter.Json.... Do you have any other docs?

scotjam’s picture

Only this from MongoDB...

http://www.mongodb.org/display/DOCS/Import+Export+Tools

It's easy to convert them to json format. I just open the file in a text editor and replace all '}\n{' with '}, {' and add '[' to the start and ']' to the end.

I was thinking I could make some code changes to the parser, for it to look more kindly at this structure
cheers
scotjam

twistor’s picture

Title: another simple example please? » Add support for the JSON lines format.
Component: Miscellaneous » Code
Assigned: Unassigned » twistor
Category: support » feature
twistor’s picture

I've made an initial commit for this. Whenever the dev release shows up, this should be in it.

http://drupal.org/cvs?commit=434614

scotjam’s picture

just brilliant.
thank you for this.
scotjam

twistor’s picture

Status: Active » Fixed

I'm guessing this is working. Any problems, open a new issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.