A database of properties: can it be done? Suggestions on the approach?
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: A database of properties: can it be done? Suggestions on the approach?
Wiki: json.merge() if you want to merge arrays.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Cave Troll
- Posts: 31
- Joined: Sat May 11, 2019 8:41 am
Re: A database of properties: can it be done? Suggestions on the approach?
To get around a number of problems, I turned to a variation that doesn't use json.path.read():
This sprang from the json.merge() suggestion. This way I always get arrays and can merge them no problem, step after step, up to the final filtered list.
Code: Select all
[h: filteredList = ""]
[h: inputValueIsNumber = isNumber(arg(2))]
[h: Arg2 = arg(2)]
[h, if(!inputValueIsNumber): Arg2 = "(?<![a-zA-Z])(" + arg(2) + ")(?![a-zA-Z])"]
[h, foreach(item,arg(0)), code:
{
[h, if(inputValueIsNumber): Matching = matches(json.get(item, arg(1)), Arg2); Matching = getFindCount(strfind(json.get(item, arg(1)), Arg2))]
[h, if(Matching): filteredList = json.append(filteredList, item)]
}]
[h: macro.return = filteredList]