discoveryjs / browser-extension-json-discovery

A browser extension (Chrome, Edge, Firefox) that changes the way you're viewing JSON
236 stars 11 forks source link

Autosuggest fields with dot #86

Open alexpts opened 12 months ago

alexpts commented 12 months ago

Input JSON:

  {
    "name": "elasticsearch2",
    "disk.total": "95gb",
    "disk.used": "12.5gb",
    "disk.avail": "82.5gb",
    "ram.max": "2gb",
    "uptime": "5.7h",
    "ip": "172.18.0.2",
    "heap.current": "473.2mb",
    "heap.percent": "46",
    "heap.max": "1gb",
    "ram.percent": "81",
    "node.role": "cdfhilmrstw",
    "master": "*",
    "id": "yVjW",
    "http_address": "172.18.0.2:9200",
    "version": "8.4.1",
    "query_cache.memory_size": "3kb",
    "query_cache.hit_count": "7092",
    "request_cache.hit_count": "1",
    "flush.total": "19",
    "flush.total_time": "39.9s",
    "get.current": "0",
    "port": "9300"
  }
]

On click to input field UI show suggest fields

image

Fields with dot in name don`t work correct.

.name - show name field

1) Autosuggest must escape name of fields. 2) How I can escape field with dot manually?

lahmatiy commented 11 months ago

Yeah, this should be fixed. However, it's a tricky one.

How I can escape field with dot manually?

You could use bracket notation in such cases, e.g. $['disk.avail'] or some.path['disk.avail'].

alexpts commented 11 months ago

Thanks!

I cant use it for top level, but it works with map syntax .() for me:

.({'disk.avail': $['disk.avail'] })

lahmatiy commented 11 months ago

Yes, it doesn't work as a mapping for arrays, but as a read property of a value operation disregarding of value's type. For arrays you need to use .() (or .map()) as you do.