• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to perform json/xml file edit via browser

 
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please help me get started with following requirement for a small in-house tool I am trying to build. This has to be browser supported.

In the file, I have following kind of info in file system:

So I am trying to develop some application (as simple as possible) that can be used to edit each sub-module information by selecting parent module name from dropdown etc in HTML/JSP page.
And I want each line of information then to presented in an editable form, which can be edited in browser and saved.
Also user should be able to append or reorder the information as well. I have not done something like this before. Please assist me.
I have recently learned python basics, so if that can help in a more simple manner, that will also do.
Note: Database is prevented. And the storage medium that I have felt should be JSON/ XML.

As I am trying this, I will also post any code that I develop.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me see if I understand your requirement.

You want a page that basically embed a list such that items (dropdowns) can move up or down. These items or dropdowns are those module information.

At the same time you want to append or add new dropdowns to this list.

Once everything is done, this list will convert to XML or JSON.

Looks doable but won't be easy, especially the moving/adding parts.
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't edit the question now, but i you can do it, the please do by deleting 'this' post. Here is more info:

Lets say I have these (in json, but just showing xml for ease):

Now in drop down, its like:

Select module:

- module1
- module2
- create new

>> when user selects module 1/2, another dropdown of submodules occurs
for module 1:

- submodule 1
- submodule 2
- create new

for module 2:

- create new


>>Now, based upon data in json, if info is present, we need to present it. When "create new" is selected, we need to add more information from a form to user and append new modules or submodules to existing data.
 
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It really doesn't matter whether the data was formatted in XML or JSON or whatever when you got it. So don't let that get in the way of your design process. You have tree-structured data and you need a way to present it for updating.
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got so less time this week, yet I managed to populate JSON data into JSP as desired using AJAX to select and dynamically request server data, and then JQUERY to modify dropdown options to populate with JSON response.
Creation of data also will not be a problem.
But I need now assistance to edit existing information - like module name, submodule name or the info. Any headway?

Example data:


Is this that the whole file needs to be loaded and mapped, and bits of it modified as needed, and that whole object again written back to file?

If that is so, any idea how to evade full write and only modify desired object.
 
Paul Clapham
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You initially mentioned a "small in-house tool" but your subsequent posts seem to indicate that you're trying to write a general-purpose tool for editing arbitrary XML and (/or?) JSON documents via the web. The latter is not a small tool, it's a large project. Do your documents have some standard features, or do they follow some standard patterns?
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So now that I have done making this, I will tell what I did actually.
1. JSP to server is done with AJAX.
2. Now there are classes that map to the JSON object, and I used Boon for this, read and write.
3. For displaying particular submodule, make AJAX call using selected module and submodule name and in response comes the data (after parsing with Boon and mapping to Modules object).
4. For edit, just edit that object and write back the JSON to flat file.

Thanks for your questions and feedback.
 
Rajdeep Biswas
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For anyone stumbling across this, here is the raw code; https://github.com/xploreraj/ytools/
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic