Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XMLquire and JSON

Posted on 2013-11-03
9
Medium Priority
?
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1600 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

609 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