json

Save JSON file to grab other data from it later

若如初见. 提交于 2021-02-19 06:04:27
问题 I want to be able to save my json file with new data and then call upon that data so that I can save new data again. Right now all it is doing is it is, when I call upon any part of the JSON file's data, staying the same the last time I manually saved it. (I did edit some code and a better description of my problem) Thank you in advance! Here is my code there is no error log: const Discord = require('discord.js'); const botconfig = require("./botconfig.json"); const fs = require("fs"); const

Convert JSON to CSV with jq

懵懂的女人 提交于 2021-02-19 05:50:08
问题 I'm trying to extract the sids, ll, state, name, smry values in my JSON file using jq and export to a csv. JSON File (out.json): { "data": [ { "meta": { "uid": 74529, "ll": [ -66.9333, 47.0667 ], "sids": [ "CA008102500 6" ], "state": "NB", "elev": 1250, "name": "LONG LAKE" }, "smry": [ [ "42", "1955-02-23" ] ] }, { "meta": { "uid": 74534, "ll": [ -67.2333, 45.9667 ], "sids": [ "CA008103425 6" ], "state": "NB", "elev": 150.9, "name": "NACKAWIC" }, "smry": [ [ "40", "1969-02-23" ] ] }, { "meta"

Gson parse to POJO with custom key

谁都会走 提交于 2021-02-19 05:38:06
问题 I have json data like this: meds: [ { MedsID: 8063, updated_at: "2015-11-04T06:59:55", treatment_date: "2015-11-04T00:00:00", name: "name" } ], scores: [ { ScoreID: 75820, updated_at: "2015-11-04T06:59:55" dialysis_flow: 233, } ], dias: [ { DiasID: 75820, updated_at: "2015-11-04T06:59:55" name: "K", } ] And here is my Entities: public class BaseData{ public long id; } public class Med extends BaseData{ public String name; public String updated_at; public String treatment_date; } public class

How to read a text file and return it as a JSON object in Node JS?

妖精的绣舞 提交于 2021-02-19 05:22:12
问题 I have a text file. I need to read the file inside a function and return it as a JSON object. The following is throwing an error "Unexpected token V in JSON at position 0" . Server.js fs.readfile('result.txt', 'utf8', function(err,data) { if(err) throw err; obj = JSON.parse(data); console.log(obj); }); result.txt looks like the following VO1: 10 5 2 VO2: 5 3 2 I think I cannot use JSON.parse directly. How do I proceed? 回答1: Assuming the following: Every line is separated by a newline

Filtering nested JSON javascript

牧云@^-^@ 提交于 2021-02-19 05:21:19
问题 I'm creating an API that takes a JSON like this: "hightlights":[ { "title":"Fun", "url":"fun/index.html", "queries": [ "music", "artists", "events", "internet" ] }, { "title":"Internet", "url":"internet/index.html", "queries": [ "javascript", "web", "internet", ] } ] I need to filter the JSON with a word given by user and return with another JSON with only object that contains the word in "queries". If word === 'music', receive: { "title":"Fun", "url":"fun/index.html", "queries":[ "music",

Filtering nested JSON javascript

瘦欲@ 提交于 2021-02-19 05:21:15
问题 I'm creating an API that takes a JSON like this: "hightlights":[ { "title":"Fun", "url":"fun/index.html", "queries": [ "music", "artists", "events", "internet" ] }, { "title":"Internet", "url":"internet/index.html", "queries": [ "javascript", "web", "internet", ] } ] I need to filter the JSON with a word given by user and return with another JSON with only object that contains the word in "queries". If word === 'music', receive: { "title":"Fun", "url":"fun/index.html", "queries":[ "music",

Accessing a single value from a json file in c#

老子叫甜甜 提交于 2021-02-19 04:26:07
问题 My json file looks something like this { lab :[ { "name": "blah", "branch": "root", "buildno": "2019" }] } so, i need to access the value of the buildno (2019) and assaign it to a variable in my program. This is my class public class lab { public string name { get; set; } public string branch { get; set; } public string buildno { get; set; } } I tried this method using Newtonsoft.json using (StreamReader r = new StreamReader(@"ba.json")) { string json2 = r.ReadToEnd(); lab item = JsonConvert

Laravel 4:: Returning models and its relationship

拜拜、爱过 提交于 2021-02-19 04:17:54
问题 I would like to return the model and part of its relationship EX:: User model public function comments() { return $this->hasMany('comments'); } Comments model public function user() { return $this->belongsTo('user'); } Can I return all comments and the user's name associated with the comment? The desired effect is $comment = Comments::find($id); $comment->user; return $comment; This will return the one comment and the associated user full model. I just need the name of the user. And this does

Passing JSON Object and List of Objects to ASP.Net Controller [duplicate]

做~自己de王妃 提交于 2021-02-19 03:38:12
问题 This question already has answers here : Post JSON array to mvc controller (3 answers) Closed 5 years ago . I need some help with the hereunder please. I have these 2 models and the method I will be using them in hereunder. public class RoleModel { public string Name { get; set; } public string Description { get; set; } public List<PermissionGroupModel> PermissionGroups { get; set; } } public class PermissionGroupModel { public int PermissionGroupID { get; set; } public string Name { get; set

XSLT 1.0 escaping double quotes and backslash in a string

假装没事ソ 提交于 2021-02-19 03:14:42
问题 I have a string like below and trying to convert into json format: Test "out" and \new Expected output is Test \"out\" and \new I tried by calling templates for escapequote - working fine for escape quotes: <xsl:template name="escapeQuote"> <xsl:param name="pText" select="concat(normalize-space(.), '')" /> <xsl:if test="string-length($pText) >0"> <xsl:value-of select="substring-before(concat($pText, '"'), '"')" /> <xsl:if test="contains($pText, '"')"> <xsl:text>\"</xsl:text> <xsl:call