Edit JSON/XML File

<< Click to Display Table of Contents >>

RayPack > 8.0 > User Guide > PackDesigner > MSI / MST / RPP Based Projects > Visual Designer Mode > System Interaction > JSON & XML files 

Edit JSON/XML File

General JSON/XML File Settings Overview

When editing a JSON/XML file, you will have several basic settings available in the editor. This is where you can configure key properties of the file before applying specific content changes.

 

Key Settings:

1.File Name:

oThe name of the JSON/XML file being edited. You can modify the file name here if necessary.

 

2.Directory:

oThe target system directory or property where your JSON/XML file will be saved or updated.

Note: This field can either accept the ID from the Directory table or a property name, but hardcoded paths are not supported, ensuring portability and flexibility. You may manually set the directory path, or use the [...] button to browse and select the appropriate directory from a standardized selection.

 

3.Component:

oThe associated component linked to the file. This enables you to define connections between the file and parts of your project.

 

4.Ignore Processing Errors:

oA checkbox that, when selected, instructs the system to proceed even if processing errors are encountered while handling the file.

 

5.File Mode Options:

oThese options define how the file should be handled whenever it already exists or if it's being created for the first time:

Create or update: Process update rules for an existing file, otherwise create a new file.

Update only: Update the file only if it already exists; skip if it doesn't.

Create only: Create the file if it doesn’t exist, but skip if it already exists.

Create or overwrite: Always create or overwrite the file with the specified initial content.

 

6.Initial Content Area:

oThis is a text box where you can input or modify the initial contents of the JSON/XML file.

oImportant:

This content is used exclusively during the file creation or overwrite process. When the file is set to "Create or overwrite" mode or if you're defining the initial content for the first time, this area allows you to specify what will go into the file upon its creation.

If you're making adjustments or applying modifications to existing JSON/XML files, you don't need to recreate the entire file here. This feature is useful for creating initial templates, simplifying the process when only minor modifications are required. Rather than having to recreate all of the file’s entries, users can focus on the one specific modification needed.

 

Editing Options via Right-Click (JSON/XML)

To make additional modifications, you can access a context menu by right-clicking the JSON/XML file within the file explorer or project tree. This menu provides various options to manage and modify the file.

 

Right-Click Context Menu:

Install first, Install earlier, Install later, Install last:

oThese options allow you to control the installation sequence of the JSON/XML file relative to other files in the project. This ensures correct dependencies or execution order are respected during installation.

 

Go to row:

oQuickly navigate to a specific row number within the JSON/XML file, enabling more precise and direct editing.

 

Remove:

oDeletes the file from the project. You will be prompted with a confirmation dialog before final deletion is executed.

 

Add new modification:

oOpens the JSON/XML modification settings screen for more advanced, targeted changes within the file, which is covered in the following section.

 

JSON/XML Modification Settings

In addition to basic editing, you can apply specific modifications to JSON/XML files. This is useful when updating or adding individual entries to a document, particularly for deeply nested structures within JSON/XML data.

 

JSONPath for JSON/XPath for XML:

JSONPath: A query syntax used to navigate and address specific properties, elements, or arrays within a JSON object. With JSONPath, you can identify a part of a JSON document to update or modify (e.g., $.store.books[0].author).

XPath: A query language used for navigating XML documents by selecting nodes (elements, attributes, text, etc.) from the document structure. It helps you target specific sections of the XML data (e.g., /catalog/book/author).

 

1.JSONPath/XPath:

oEnter the expression that will define the path to the part of the JSON/XML file you want to modify. This path is essential to targeting the correct node or property for the modification.

For JSON: Use JSONPath expressions to specify properties and array indices.

For XML: Use XPath expressions to target elements, attributes, or text within the XML document.

 

oXPath Guidelines for XML Creation: XPath is used to reference and modify elements in XML files. Here are some simplified examples:

Valid: /bookstore/book – A clear path to create a new "book" element in the bookstore.

Valid: /bookstore/book[2] – Creates a "book" element in the second position if there’s already one book.

Valid with predicates: /bookstore/book[position()<3] – Used to modify existing elements, not for creating new ones.

Invalid: //title[@lang='en'] – Wildcards select multiple elements and cannot be used to create new elements.Enter topic text here.

 

2.Value Type:

oFor JSON:

You can set the type of data being modified based on standard data types such as string, number, boolean, etc.

oFor XML:

XML values are always stored as strings. Ensure that any value entered in the modification panel is formatted as a string, even if it represents numeric or other data types in the actual XML structure.

 

3.Delete:

oChoose this option to delete the property or node at the specified JSONPath/XPath.

oThe system will locate the property or node using your path expression, and upon confirmation, it will remove this part of the file.

 

4.Create Only:

oThis option creates a new value for the specified JSONPath or XPath, but only if the property or node does not currently exist. Existing values remain unchanged.

 

5.Update Only:

oUse this option to update an existing property or node if it is found using the JSONPath or XPath. If the specified property or node doesn’t exist, the operation will be skipped.

 

6.Set:

oThis option combines the create and update behaviors. If the target property or node does not exist, it will create it; otherwise, it will update the existing one.

 

7.Condition (Optional):

oYou can create advanced, conditional logic under which the modification will apply, ensuring precise control over the file's behavior.