2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 <2023> 2024 2025 | Index | 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 <2023> 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Create NTTable from JSON |
From: | "Veseli, Sinisa via Core-talk" <core-talk at aps.anl.gov> |
To: | "core-talk at aps.anl.gov" <core-talk at aps.anl.gov>, Karl Vestin <karl.vestin at ess.eu> |
Date: | Wed, 5 Apr 2023 14:22:47 +0000 |
Hi,
I am not sure if this helps, but if the object has correct structure as far as number/type columns, at the moment you could do something like this:
>>> nt = NtTable([STRING, INT, DOUBLE])
>>> nt.setColumn(0, ['xx', 'yy', 'zz'])
>>> nt.setColumn(1, [1, 2, 3])
>>> nt.setColumn(2, [11.1, 22.2, 33.3])
>>> nt.useNumPyArrays=False
>>> myString = json.dumps(dict(nt))
>>> print(myString)
{"labels": [], "value": {"column0": ["xx", "yy", "zz"], "column1": [1, 2, 3], "column2": [11.1, 22.2, 33.3]}, "descriptor": "", "timeStamp": {"secondsPastEpoch": 0, "nanoseconds": 0, "userTag": 0}, "alarm": {"severity": 0, "status":
0, "message": ""}}
>>> nt2 = NtTable([STRING, INT, DOUBLE])
>>> nt2.set(json.loads(myString))
>>> print(nt2)
epics:nt/NTTable:1.0
string[] labels []
structure value
string[] column0 [xx, yy, zz]
int[] column1 [1,2,3]
double[] column2 [11.1,22.2,33.3]
string descriptor
time_t timeStamp
long secondsPastEpoch 0
int nanoseconds 0
int userTag 0
alarm_t alarm
int severity 0
int status 0
string message
>>>
Sinisa
--
Siniša Veseli
Scientific Software Engineering & Data Management
Advanced Photon Source
Argonne National Laboratory
sveseli at anl.gov
(630)252-9182From: Core-talk <core-talk-bounces at aps.anl.gov> on behalf of Karl Vestin via Core-talk <core-talk at aps.anl.gov>
Sent: Wednesday, April 5, 2023 8:25 AM To: core-talk at aps.anl.gov <core-talk at aps.anl.gov> Subject: Create NTTable from JSON Dear all,
Are there any functions available to generate a NTTable from a JSON object or JSON schema? I have found a function to generate JSON from a PVObject, but not the other way around.
Anyone have insights to share?
Karl Vestin Group Leader Hardware and Integration Integrated Control Systems Division European Spallation Source ERIC
+46721792066 P.O Box 176, SE 221 00 Lund, Sweden Visiting address: Odarslövsvägen 113, Lund
|