Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

trivers json node as node type

private void processNode(JsonNode jsonNode, StringBuilder yaml, int depth) {
    if (jsonNode.isValueNode()) {
        yaml.append(jsonNode.asText());
    }
    else if (jsonNode.isArray()) {
        for (JsonNode arrayItem : jsonNode) {
            appendNodeToYaml(arrayItem, yaml, depth, true);
        }
    }
    else if (jsonNode.isObject()) {
        appendNodeToYaml(jsonNode, yaml, depth, false);
    }
}
Comment

trivers json node as node type2

private void appendNodeToYaml(
  JsonNode node, StringBuilder yaml, int depth, boolean isArrayItem) {
    Iterator<Entry<String, JsonNode>> fields = node.fields();
    boolean isFirst = true;
    while (fields.hasNext()) {
        Entry<String, JsonNode> jsonField = fields.next();
        addFieldNameToYaml(yaml, jsonField.getKey(), depth, isArrayItem && isFirst);
        processNode(jsonField.getValue(), yaml, depth+1);
        isFirst = false;
    }
        
}
Comment

PREVIOUS NEXT
Code Example
Java :: java circular buffer implementation on array 
Java :: correct lcd initialize 
Java :: fibonacci series 
Java :: javafx treeview directory 
Java :: com.google.firebase.database.DatabaseException: Serializing Arrays is not supported, please use Lists instead 
Java :: kakao tech tcp close_wati 
Java :: choose image java 
Java :: exemple javafx 
Java :: bukkit scheduler self cancelling task 
Java :: final variables in java 
Java :: Caused by: java.lang.ClassNotFoundException: 
Java :: && java 
Java :: how to make a for loop increment by 2 in java 
Java :: matrix rotation in java 
Java :: java indexof not found 
Java :: java program to print vowels in a string 
Java :: java stream group by multiple fields 
Java :: directory size java 
Java :: void setup 
Java :: java swing tablecellrenderer 
Java :: schantalgebra 
Java :: how to calculate min, max and average and write the output into into a text file in java 
Sql :: mysql how to truncate table with foreign keys 
Sql :: guid to string sql 
Sql :: freemysqlhosting keeps deleting tables 
Sql :: oracle table privileges 
Sql :: wilayah indonesia sql 
Sql :: mysql convert timestamp to date 
Sql :: import sql file from laravel 
Sql :: how to drop databaselink in oracle 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =