· Feb 27, 2020

Quote Numbers in Json Stream

Hello Community,

My Intersystems Caché Version: 1.2014 (Can't update now.)

I have the following issue:

I have for example an articlenumber with 15049950, which is numeric. But sometimes it can also be an alphanumeric string like PK15049950.

How can i set numbers always to string in Json Stream with quotes like "15049950".

Code Example:

set object = ##class(%ZEN.proxyObject).%New()

set articlenumber = "15049950"

set object.articlenumber = articlenumber

set x = ##class(%ZEN.Auxiliary.jsonArrayProvider).%WriteJSONStreamFromObject(.json,object)

Will output:


 "articlenumber": 15049950



but I want always:


"articlenumber": "15049950"



Thank you and best regards!

Discussion (3)0
Log in or sign up to continue

Through %ZEN.proxyObject is unlikely to work, since the q parameter cannot be disabled in this case

q - output numeric values unquoted even when they come from a non-numeric property

Use your own class, for example:

Class dc.test Extends %RegisteredObject

Property articlenumber As %String;

object ##class(dc.test).%New()
object.articlenumber "15049950"