Open flybynight27 opened 4 years ago
I think we are mostly using it on Objects, not strings. So we haven't hit it. But it is a valid case.
Submit your changes and a test or two to cover it and will get it inlcuded.
Thanks ;-)
Todd
Thanks for the validation that I'm not [completely] crazy.
Do you think this should be a change to the existing function, or a new CF in the mix?
For my purposes, I have just added a new version, that I called JSON.ArrayFromRelatedText ( Field )
Calculation:
"[ \"" &
Substitute(
List ( Field ) ;
"¶" ; "\", \""
)
&
"\" ]"
Test:
JSON.ArrayFromRelatedText ( Related::Item )
Expected Result:
[ "apple", "orange", "plum\rbanana" ]
Here is a file with that added, plus a couple test records. JSONAdditionsKruegerMod.fmp12.zip
Not sure if this fits your naming conventions or dev standards, but it worked for me. I'm also probably not doing the whole Git thing correctly. ;^)
I'm having trouble getting things to come out correctly in my JSON with using this CF. I was getting things like this in my JSON:
{“options” : [ “[John Doe, Jane Smith]” ]}
When what I want is:{“options” : [ “John Doe”, “Jane Smith” ]}
I can modify the CF to get what I am after, by adding some escaped quotes, but I’m curious if anyone else has run into this before. Am I using it wrong? Here is an example of my usage:
JSONSetElement ( "{}" ; "options" ; JSON.ArrayFromRelated ( Related_TO::FieldName ) ; JSONString )
If I try to use JSONArray as the last parameter, I get this:{"options":[]}
Looking at the 2 tests for this function, the one that references Related::Item doesn't seem like it would actually be a useful/valid result, if the items aren't quoted. Test:
JSON.ArrayFromRelated ( Related::Item )
Result:[apple,orange,plum\rbanana]
I would expect this to be a more useful/valid result:["apple","orange","plum\rbanana"]
Maybe it is only meant to be used with numbers or objects, not strings?