Enhancement request: Preferences: Defaults for JSON quote provider

Hi,

it would be great if PP-preferences could include a set of default values for the 10 parameters of the JSON quote provider–there is a lot of fields and they are typically very techy.

Also, being able to set a preferred quote provider in the first place would be great.

Currently I perform both of this by programmatically editing the XML file. It works, but it is brittle and breaks on occasional schema changes.

Thanks & best regards,
Dietmar

Default values won’t help much since there is no JSON standard. Every JSON source can decide what ever they want as values. But the PopUp over the “i” gives you an idea:

This is done when you use Built-In or Yahoo Finance, neither of them must be configured.

Why not using the security copy feature:

Just adjust ISIN, SYMBOL and WKN which you need to type anyway when editing XML.

(sorry, had to delete some images due to forum restrictions for new users)

Excactly because there is no standard is why I would consider it helpful to have them in Help→Preferences…, so that each user can configure defaults if needed. If someone uses a JSON source at all, chances are that there is a preferred one (maybe custom-made) which requires the same params over and over again:

Editing programmatically means going through the XML-serialized PP database (~88MB in size, ~1.7 million lines) by (Python-)code to synchronize a large number of positions with my actual portfolios. Manual copy/edit is just not an option for me:-(

1 Like

Just as a 10 seconds thought, PP could analyze the source and build a collection of suitable pathes as follows:

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.*;

public class JsonPathScanner {

    private static final ObjectMapper MAPPER = new ObjectMapper();

    public static void main(String[] args) throws Exception {
        String json = "{ /* dein JSON hier */ }";

        JsonNode root = MAPPER.readTree(json);

        Map<String, JsonNode> paths = new LinkedHashMap<>();
        collectPaths(root, "", paths);

        // Alle Pfade ausgeben
        paths.keySet().forEach(System.out::println);
    }

    private static void collectPaths(JsonNode node, String prefix, Map<String, JsonNode> paths) {
        if (node.isObject()) {
            node.fieldNames().forEachRemaining(field -> {
                String path = prefix.isEmpty() ? field : prefix + "." + field;
                JsonNode child = node.get(field);
                paths.put(path, child);
                collectPaths(child, path, paths);
            });

        } else if (node.isArray()) {
            for (int i = 0; i < node.size(); i++) {
                String path = prefix.isEmpty() ? String.valueOf(i) : prefix + "." + i;
                JsonNode child = node.get(i);
                paths.put(path, child);
                collectPaths(child, path, paths);
            }

        } else {
            // Primitive (String, Number, Boolean, null)
            // prefix ist hier schon der komplette Pfad
            paths.put(prefix, node);
        }
    }
}