Build JSON from NotesView with support of multi-value fields


_fld:="refName":"refSub":"refStrength":"refWeakness";

json:="";

@For(n :=1; n<=@Elements(_fld); n:= n + 1;

@If(
	@Elements(
		@GetField(_fld[n])
		)>1;
			json := json +  @Transform ( _fld[n]; "_fn" ;  "\"" + _fn + "\":") + "[" + @Implode(@Transform( @GetField(_fld[n]) ; "_fn" ; "\"" + _fn + "\"" ) ; ",") + "]," ;
			json := json +
				@Transform (
					_fld[n]; "_fn" ; "\"" + _fn + "\":\"" + @Text ( @GetField ( _fn) ) + "\"" + ",")
	)
);


"{ \"unid\":\""
+@Text(@DocumentUniqueID)+"\"," + @LeftBack(json;1) + + "}"
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...