Solved

XMLquire and JSON

Posted on 2013-11-03
9
284 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 30

Expert Comment

by:Alexandre Simões
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Assisted Solution

by:chima
chima earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This is a "body"?
0
 

Author Closing Comment

by:chima
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now