Solved

XMLquire and JSON

Posted on 2013-11-03
9
289 Views
Last Modified: 2013-11-24
Hello,
I would think that a search on the internet would result in getting my question answered, but I did not find it.
My question is this; is there a tool like XMLQuire that does the same for Json?  
I looked to see if xmlquire can provide the xpath for a json file?

Might you know of one?
0
Comment
Question by:chima
  • 5
  • 3
9 Comments
 

Author Comment

by:chima
ID: 39620577
I found jsonPath, yet I do not think that it generates the xpath.  It generates or uses it own path syntax to get the elements.  I need the xPath for a Json file; http://goessner.net/articles/JsonPath/
Comments?

Might jsonEditor provide the xpath?
http://xmlgrid.net/jsonEditor.html
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 400 total points
ID: 39621188
What do you need to accomplish with a hypothetic jsonPath?
Is this a backward compatibility issue? You had XML now you have JSON and want everything to work as smooth as possible?

The main problem is that JSON and XML are not directly compatible, meaning that not all XPath operators will work on both.

Explain me better what you're actually trying to accomplish.
0
 

Author Comment

by:chima
ID: 39621515
AlexCode
jsonPath is not hypothetical; http://goessner.net/articles/JsonPath/, yet one should ask whether it is approved by the W3C.

I believe this statement clarifies this;"The main problem is that JSON and XML are not directly compatible, meaning that not all XPath operators will work on both."

This is why jsonpath has different symbols:
elements with its XPath counterparts.

XPath  JSONPath  Description  
/          $                   the root object/element  
.          @                  the current object/element  
/       . or []              child operator  
..        n/a                parent operator  
//         ..                  recursive descent. JSONPath borrows this syntax from E4X.  

etc, etc...

Therefore, it is possible that xpath for Json does not exist.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39621558
For me it's clear that XPath for JSON doesn't exist.
XPath is designed to transverse XML documents not JSON.
As you also agreed, XML and JSON are two completely different formats, which takes me back to the main question of my post that you didn't answer:

What are you trying to achieve?
Why do you need XPath notation to transverse JSON, even knowing in advance that it can never be consistent?
0
 

Assisted Solution

by:chima
chima earned 0 total points
ID: 39622006
Alexcode, I do apologize that I did not answer your question.  I'm not an expert with xpath, nor using xpath, but let's assume that there is an app that accepts xml files as its data input by using the xpath from the xml file.  Now let's say that the input file changes to be a json format, but the app still uses xpath to get the data.  Then I would need to get the data from the json file using xpath.  

Maybe there is a json-path to xpath converter?
This thought comes to mind because xmlquire generates the xpath for the xml.  Then I thought that there might be; jsonquire generates the xpath from the json.
Now I know there isn't such a "process/tool/app" because the formats are different.
Thank you for your comments.  Your points are coming shortly.
0
 
LVL 44

Assisted Solution

by:Rainer Jeschor
Rainer Jeschor earned 100 total points
ID: 39622036
Hi,
why not converting JSON to XML? Then you can still use the existing XPath processing.
Like
http://code.google.com/p/x2js/

But still: where do you get the JSON from? What is your "workflow" / business process?
Which coding / technologies are used?

Just my 2ct.
Rainer
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39623000
Hi mate.

In my opinion you'll have much less trouble if you just rewrite the logic for the new data format (JSON).
The best approach would be, in my opinion, to abstract the file reading code so that you could still call the appropriate reader depending on the received file format (XML, JSON or whatever new format it might come in the future).

I understand that you want to touch the code the less possible, but if you want to do it properly just rewrite that bit of code that reads the file.
0
 

Author Comment

by:chima
ID: 39659418
This is a "body"?
0
 

Author Closing Comment

by:chima
ID: 39672353
I do apologize for the delay/forgetting to get back to this question.  Thank you for the clarification.  Alexcode, yes rewriting the code would be better for it to accept all formats.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question