JSON

751

Solutions

749

Contributors

JavaScript Object Notation, or JSON, is human-readable text used when transmitting data objects consisting of attribute:value pairs between a server and a web application as an alternative to XML. JSON, while it is originally derived from JavaScript, is a language-independent data format. Code for parsing and generating JSON data is available in many programming languages.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am trying to get the LINQ C# statement together to do the following:

I have two filled IEnumerables:

IEnumerable<Customer>
IEnumerable<CustomerGroup>

The models looks like this:

Customer Model:

public int CustomerId { get; set; }

public string CustomerName { get; set; }

public int? CustomerChildId { get; set; }

public CustomerGroup CustomerGroup { get; set; }

public IEnumerable<Customer> Children { get; set; }

CustomerGroup Model:

public int CustomerGroupId { get; set; }

public int CustomerId { get; set; }

public string CustomerGroupName { get; set; }

I will have both IEnumerables populated.

What I am trying to do is get a new IEnumerable<Customer> where CustomerChildId IS NULL from
the original IEnumerable<Customer> then the CustomerGroup is a 1 to 1 on the CustomerId I need
to populate as the CustomerGroup and then populate the list of Children where the CustomerChildId equals the CustomerId.

I am needing this dataset to try and generate a JSON result something like this"

  {
    "CustomerId": 10,
    "CustomerName": "ABC Corp",
    "CustomerGroup": { "CustomerGroupId": 12, "CustomerGroupName": "Group A" },
    "Children": [
      { "CustomerId": 15, "CustomerName": "XY Inc." },
      …
      { "CustomerId": 16, "CustomerName": "Harrows" } ]
  }
0
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

i have a json file, which contains KV pairs like below.

{
"app1_ds1_ds_jndi": "value1",
"app1_ds1_ds_url": "value2",
"app1_ds1_ds_useri": "value3",
"app1_ds1_ds_pwd": "value4",


"app1_ds2_ds_jndi": "value5",
"app1_ds2_ds_url": "value6",
"app1_ds2_ds_user": "value7",
"app1_ds2_ds_pwd": "value8",


"app2_ds1_ds_jndi": "value9",
"app2_ds1_ds_url": "value10",
"app2_ds1_ds_user": "value11",
"app2_ds1_ds_pwd": "value12",

}


I want to parse the above file to grep for all app1 datasources, ignoring other apps like app2, app3 ..etc., and construct an array of hashes in ruby like below.




[{jndiname: "value1",  url_name:"value2" user_name: "value3", Password:"value4"},
{jndiname: "value5",  url_name:"value6" user_name: "value7", Password:"value8"}
]
0
Dear sirs,
Please help, how can I avoid this exception. It happens when my http response includes an empty List in the body.

org.springframework.web.client.RestClientException: Error while extracting response for type [java.util.List<?>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 1] at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:115) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:991) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:974) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:725) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:698) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:649) at com.finger.services.AppRestTemplateService.doHandleListRequest(AppRestTemplateService.java:140) at

Please, assist
0
I am trying to make a request to Google Cloud NLP API to obtain sentiment analysis for a piece of text. I used Postman to design the correct request, and I was able to get a valid response using Postman. However, when I try to make the same request from Swift, it gives me an error. The error and code snippet used to make the request is shown below.

func sendAPIRequest(with text: String){

    print("Text: ", text)
    let jsonRequest = [
        [
        "document":[
            "type":"PLAIN_TEXT",
            "language": "EN",
            "content":"'Lawrence of Arabia' is a highly rated film biography about British Lieutenant T. E. Lawrence. Peter O'Toole plays Lawrence in the film."
        ],
        "encodingType":"UTF8"
    ]
        ]

    let jsonObject = JSON(jsonRequest)


    let headers: HTTPHeaders = [
        "X-Ios-Bundle-Identifier": "\(Bundle.main.bundleIdentifier ?? "") ",
        "Content-Type": "application/json"
    ]
    let APIRequest = Alamofire.request("https://language.googleapis.com/v1/documents:analyzeSentiment?key=\(gCloudAPIKey)", method: .post , parameters: jsonRequest as? [String: Any], encoding: JSONEncoding.default , headers: headers).responseJSON { (response) in
        print(response)
        if let json = response.result.value {
            print("JSON: \(json)")
        }
    }

Open in new window


Error:
JSON: {
error =     {
    code = 400;
    details =         (
                    {
            "@type" = "type.googleapis.com/google.rpc.BadRequest";
            fieldViolations =                 (
                                    {
                    description = "Must have some text content to annotate.";
                    field = "document.content";
                }
            );
        }
    );
    message = "One of content, or gcs_content_uri must be set.";
    status = "INVALID_ARGUMENT";
};
}

Open in new window

0
I know similar questions to this have been asked before but I'm having difficulty implementing the solutions.  I have a very simple access database which uses an API to get outside data.  I am getting the correct data now, but the response is JSON that I need to parse into a table and/or update rates in an existing table.  Essentially I am trying to do the same thing as in this question:

https://www.experts-exchange.com/questions/28952370/Parse-JSON-with-VBA-Access-2010.html

I have no idea how to implement this though.  I am a complete novice at JSON and using an API.  Can anyone give me some pointers in laymans terms on how to implement this?  I need to know what code to put into a module, and how to call it.  Once I see it working Ill be able to run with it I think, but right now Im very confused.
0
Hi there,

Can anyone help me for below query.
How to hit POST API through TDL language which can send data in JSON format from Tally and get response.  Please send us complete code for this.

      
I am using below code but this is not working.

[#Menu: Gateway of tally]
      Add: Item: send data : Call: Senddata
      
[Function: Senddata]
            
      00      :      Walk            : SendDatacoll      
      10      :      End Walk
      20      :      Return
      
[Collection      : senddatacoll]
      Remote URL            : "API url"
      RemoteRequest        : RepsalesVch       : UTF8
      ClientOnly             : Yes
      KeepSource      : yes
      JSON Object            : yes
      
      
      
[Report      : RepsalesVch]
      Form: RepsalesVch
      
[Form :      RepsalesVch]
      Part      : RepsalesVch Body
      Button      : Export button
      JSONTag      : "Report"
 
                        
[Part: RepsalesVch Body]
      JSONTag            : "Body"
      Line            :  RepsalesVchdetails
      
[Line:      RepsalesVchdetails ]
            Field            : ParCDBId, Partnername  , ActiveStatus  
            JSONTag            : "Details"


[Field:      ParCDBId ]
      Set as             :   "NDL002"
      JSONTag       :       "ID"
      
      
[Field                  :      Partnername ]
      Set as             :       "ABC PVT LTD"
      JSONTag            :      "ITEMNAME"
      
      
[Field                  :      ActiveStatus ]
      Set as             :       "1"
      JSONTag            :      "Active"
      

Regards
Pushpa Adhikari
0
I have a json file attached, I need java code to read it and extract to several json files 1 per json record. This has to be in JAVA. I have attached the file. It has test data.\
So in the example I need 3 json files.

example:
[{"PositionID":"1","Filter":"Non TB - ML C&S","CloseofBusiness":"May 21 2018","Source":"Janus"},{"PositionID":"2","Filter":"Yes TB - BOA","CloseofBusiness":"July 31 2018","Source":"Fidelity "},{"PositionID":"3","Filter":"Non TB - VANGUARD INDEX 500","CloseofBusiness":"Jun 31 2018","Source":"Vanguard "}]

There are 3 json records I need 3 json files from this 1 json  entry. So I need code for this fast.
simulated_json.txt
simulated_json.txt
0
I have created a LINQ to return data from SQL server in JSON format which contains nested values.
Attach the code and output, the JSON is showing duplicate values for FieldID:6

var query =  from g in entity.ConfigSearchFieldGroupings
                         join f in entity.ConfigSearchFieldGroupingFields
                         on g.GroupingID equals f.GroupingID
                         join d in entity.ConfigDataFields
                         on f.FieldID equals d.FieldID
                         join ss in entity.ConfigSelections
                         on d.FieldID equals ss.FieldID into t
                         from rt in t.DefaultIfEmpty()
                         join s in entity.ConfigSourceSystems
                         on d.SystemCode equals s.SystemCode
                         where g.IsActive == true
                         && d.IsActive == true
                         && s.IsActive == true
                         && g.GroupingID == siGroupingID
                         && d.IsSearchable == true
                         select new
                         {
                             g.GroupingName,
                             f.FieldID,
                             d.FieldName,
                             d.FieldText,
                             d.FieldDescription,
                             d.FieldCategory,
                             d.FieldDataType,
                             d.FieldLength,
                             

Open in new window

0
getting api data from posts from another sources to django
hello guys ,

is there any way where

when users can add the link of the post they want to save and the django should add that post allong with description and image to database

eg:

https://www.reddit.com/r/memes/comments/91jdgp/everything_goes_back_to_spongebob/

if i want to save this post

then dango should get data from this post as a json format and should save this post image, description ,title and all to the database

i know this can only be done using api/praw

but cant understand how to make it happen

any kind of help is appreciated
0
Hello,
Im trying to translate this code from https://securionpay.com/docs/api#checkout-request-sign.
EXAMPLE SIGNING


export checkout_request='{"charge":{"amount":499,"currency":"EUR"}}'
export signature=`echo -n "$checkout_request" | openssl dgst -sha256 -hmac 'pr_test_tXHm9qV9qV9bjIRHcQr9PLPa' | sed 's/^.* //'`
echo -n "$signature|$checkout_request" | base64
        

EXAMPLE SIGNED CHECKOUT REQUEST


Y2Y5Y2UyZDgzMzFjNTMxZjgzODlhNjE2YTE4Zjk1NzhjMTM0Yjc4NGRhYjVjYjdlNGI1OTY0ZTc3OTBmMTczY3x7ImNoYXJnZSI6eyJhbW91bnQiOjQ5OSwiY3VycmVuY3kiOiJFVVIifX0=
				

Open in new window


to Ruby on Rails

I ended with

       
 checkout_request='{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 secret_key = 'sk_test'
 @signature = Base64.urlsafe_encode64(OpenSSL::HMAC.hexdigest('sha256', checkout_request, secret_key) + "|" + checkout_request)

Open in new window


which isn't valid and its not exacly translation of the script.

When i test shell version with my secret key it works.
I tried Base64.urlsafe_encode64, encode64, strict_encode65, I tried digest instead of hexdigest. All kinds of way because I desperatly can't make it work. I think its about checkout_request data because it translates to this
 
2.5.0 :001 > '{"charge":{"amount":5,"currency":"EUR","capture":true}}'
 => "{\"charge\":{\"amount\":5,\"currency\":\"EUR\",\"capture\":true}}" 

Open in new window

and therefore signature is created with `\` before quote

question on stackoverflow: https://stackoverflow.com/questions/51506282/json-and-generating-signature
0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Trying to fetch ID in response that is stored in database of Post request. In table ID is autogenerated. tried one code but it is not working. Please suggest.

    public HttpResponseMessage Post(List<DelegateTable> delegatetable)
        {
            try
            {
                using (ShowContext delegateContext = new ShowContext())
                {
                    DelegateTable delegates = new DelegateTable();
                    List<DelegateTable> list1 = new List<DelegateTable>();
                  
                    foreach (DelegateTable item in delegatetable)
                    {
                       
                        delegates.Salutation__c = item.Salutation__c;
                        delegates.First_Name__c = item.First_Name__c;
                        delegates.Last_Name__c = item.Last_Name__c;
                        delegates.Account_Name__c = item.Account_Name__c;
                        delegates.Contact_Email__c = item.Contact_Email__c;
                        delegates.Category__c = item.Category__c;
                        delegates.Conference_Type__c = item.Conference_Type__c;
                        delegates.Conference_Selection__c = item.Conference_Selection__c;
                        delegates.Payment_Status_Interface__c = item.Payment_Status_Interface__c;
                        delegates.Barcode__c = item.Barcode__c;
                        delegateContext.delegates.Add(delegates);
                       
            

Open in new window

0
How to multiple update data using put method web api. I have used single update but i am unable to write code for multiple update.

   public HttpResponseMessage Put(DelegateTable delegatestable)
        {
            try
            {
             
                using (var ctx = new ShowContext())
                {

                    var delegatedata = ctx.delegates.FirstOrDefault(s => s.Barcode__c == delegatestable.Barcode__c);

                    if (delegatedata != null)
                    {
                        if (delegatestable.Salutation__c!=null)
                        {
                            delegatedata.Salutation__c = delegatestable.Salutation__c;
                        }
                        if (delegatestable.First_Name__c != null)
                        {
                            delegatedata.First_Name__c = delegatestable.First_Name__c;
                        }
                        if (delegatestable.Last_Name__c != null)
                        {
                            delegatedata.Last_Name__c = delegatestable.Last_Name__c;
                        }
                        if (delegatestable.Account_Name__c != null)
                        {
                            delegatedata.Account_Name__c = delegatestable.Account_Name__c;
                        }
                        if (delegatestable.Contact_Email__c != null)
                        {
                            delegatedata.Contact_Email__c = 

Open in new window

0
Hi guys,

I am curious about the benefits of using SDKs. Personally, I prefer avoiding third-party libraries, especially if I don’t see any benefits of having serialized JSON output in class models (I have found this to be the case when using JavaScript, NodeJS, PHP, Python, and other functional programming languages). When using serialized JSON models in Java, C++, C#, and ActionScript, I observed a decline in performance.

However, I am aware that companies including Google, Amazon, Salesforce, etc are generating REST API services for SDK code for developers to consume.
 
What have you found to be the main pros/cons of using SDK, and what are your personal preferences regarding which REST SDK is best for various languages?

Best,
David
0
Hi,

I'm just starting out writing a custom extension for VSTS; within task.json i have an input picklist ($location) thats bound to a datasource which retrieves a list of locations. I want to then use the selected location to filter the results for another input picklist. But the endpoint url does not contain the location and trying to filter the json result using $location in resultSelector does not return any results. (i have replaced $location in resultSelector with text to confirm the datasource is ok). Here's the code im using, any suggestions on where im going wrong please?:

"target": "networkSG",
"endpointId": "$(ConnectedServiceName)",
"endpointUrl": "{{{endpoint.url}}}/subscriptions/$(endpoint.subscriptionId)/resourcegroups/$(resourceGroupName)/providers/microsoft.Network/networkSecurityGroups?api-version=2018-02-01",
 "resultSelector": "jsonpath:$.value[?(@.location ==$(location))].name",
 "parameters": { "location": "$(location)" }
0
I have a desktop App dealing with images.  A couple of years ago we built a C# executable that makes JSON calls in order to transact with FaceBook so that users of my desktop App could upload images directly to their Facebook timeline.  All good.  But now, Facebook is changing their scheme, and they are deprecating one "permission" that we needed in order to do this.  Now Facebook says the new scheme should use a "shared dialog" but they seem only to offer support for Android, iOS, and web-servers.  My question is: how can a windows desktop App do the new scheme? Is it possible?
0
Hello, I need assistance with Highcharts.  The pie chart is able to be created, but I noticed that once the "data" variable in the "series" is added, everything else afterward the code, the font is bolded like some syntax is wrong.  In the code below, the colorByPoint is bolded.

This is the json code:

$raw_json = json_encode($dpName, JSON_NUMERIC_CHECK);
$raw_json = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9_]*)":/','$1:',$raw_json);

result of $raw_json:
[{name:"Backporting - 1660",y:1660,color:"#ed7d31"},{name:"EITS Managed - NEW - 23",y:23,color:"#135fa0"},{name:"Icon Related - 2",y:2,color:"#72c4a0"},{name:"Valid - 416",y:416,color:"#548235"},{name:"Needs Risk Acceptance - 89",y:89,color:"#cc99ff"},{name:"Discrepancies - 89",y:89,color:"#ffc000"},{name:"Pending Research - 269",y:269,color:"#258e60"},{name:"EITS Managed - 374",y:374,color:"#003366"},{name:"RBD - 383",y:383,color:"#5b9bd5"}]


$(function () {
    var chart;
    $(document).ready(function() {
      
    var pieContainer = new Highcharts.Chart({
        chart: {
        renderTo: 'pieContainer',  
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
    title: {
        text: '<?php echo date("m/d/Y")." EARS EOL Analysis (using EARS Report ".$format->formatdate($data['ears'][0]['week_date'],"m/d/Y").")"; ?>',
        style: {
          color: '#000',
          fontSize: '14px',
          fontWeight: "bold"  
        }
    },
  

Open in new window

0
Hi,

I've a table on AWS Redshift with couple of columns in JSON format.
So i'm using JSON_EXTRACT_PATH_TEXT Function to query the data in the JSON format cloumn.

For example ,

SELECT user,json_extract_path_text(payload,'code') as payload_code FROM activity_log.lx4_logs
where event_reference LIKE 'My Dashboard%'; .

So the output look like following with two coloumns

User       | Code
user1      | ["13877512003","13877642003","10078402003","13901222003","10118722003"]
user2     |["105700520150300750","106468920140600750","112279220150300750","104693120060101500","122805820150600750"]
user3    |NULL
user4    |["10112472015"]

Is there a possibility to get the output, into rows like below without any quotation, square brackets etc please ?

User       | Code
user1      |13877512003
user1      |13877642003
user1      |10078402003
user1      |13901222003
user1      |10118722003
user2     |105700520150300750
user2  |106468920140600750
user2   |112279220150300750
user2  |104693120060101500
user2  |122805820150600750
user3    |NULL
user4    |10112472015

Thanks
0
id child parent
1  522   521
1  523   521

id reading_date            result       child parent
1  2017-05-09 23:16:53    jsondata       523  521
2  2017-05-09 23:16:53    jsondata       522  521
3  2017-05-09 23:29:02    jsondata       523  521
4  2017-05-09 23:29:02    jsondata       522  521
5  2017-05-10 00:29:02    jsondata       523  521
6  2017-05-10 00:29:02    jsondata       522  521

Here I want to add all child jsondata by date by parent

for example add records 1+2 , 3+4, 5+6

the query
SELECT DISTINCT on(reading_date) reading_date,id, instrument,parent,test  FROM formula_data p   WHERE p.parent =521 ORDER BY reading_date, instrument  

Open in new window

will be fine , but JPA is not supporting distinct on
 


Here parentInstrumentId is 521. Problem withthe below code is it loop again and again .

      
@Override
	public void processChildFParent(long parentInstrumentId) {
		//Get all records by parent id		
		List<FormulaData>  formulaDataLst = fDataService.findByParent(parentInstrumentId);			
		formulaDataLst.forEach(formulaData -> {	
			//Get all records 		
			List<FormulaData>  formulaDataLst4Process = fDataService.findByParentAndReadingDate(formulaData.getParent(),formulaData.getReadingDate());	
			formulaDataLst4Process.forEach(processData -> {		
				try {				
					
					JSONObject jsonObj = new JSONObject(processData.getTest());					
					JSONArray arr = jsonObj.getJSONArray("formulaData");
					for (int i = 0; i < arr.length(); i++)
					{					
		

Open in new window

0
Using PHP I want to insert a JSON key, do I have to read the entire string into a variable, use json_decode to turn it into an array, insert the string as an array key and value, then json_decode the whole thing, or is there an easier way to push the JSON key into the existing JSON?

eg: adding comment 3:

{
  "page": {
    "name": "inc",
    "location": "sop",
    "comments": {
      "1": "Hello this is a comment",
      "2": "Hello this is another comment"
    }
  }
}

Open in new window

0
Cloud Class® Course: CompTIA Healthcare IT Tech
LVL 12
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Run-Time Error Received
Receiving the above message (Run-time Error -2047012889 The Server Name or Address could not be resolved') when using a MSXML2.XMLHTTP60 object to send a POST request to the specified URL.

Any ideas where to look?

NOTE : The code is VB6

I've tried a few things with security etc, but still getting the same response.

The general code is as follows (Note the ApplIcation ID has been replaced with the Generic Note)

   Dim myMSXML As MSXML2.XMLHTTP60
   
    Dim AuthURL As String

    AuthURL = "https://identitysso.betfair.au/api/login"

    Set myMSXML = CreateObject("MSXML2.ServerXMLHTTP")
     
    myMSXML.open "POST", AuthURL, False
    myMSXML.setRequestHeader "Accept", "application/json"
    myMSXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    myMSXML.setRequestHeader "X-Application", "<Application Code>"
   
    myMSXML.send "userName=" & sUserName & "&password=" & sPassword
0
My requirement is to store multiple data types in same column of a hive table.
And also be able to read that data .e.g. if one records has array value for that column and another record has struct value or string , I may be able to fetch that value accordingly.

I could store json data as avro in hive table with data type of string for that particular column( since spark/sqlcontext inferred the data type as string for multiple data types in the same column).I am not able to operat on that data.I just can simply read by select columnname from table.

I have tried to use uniontype to load that column-table data(string) into another table with uniontype as data type for that column but it erred saying mismatch.

Error while compiling statement: FAILED: SemanticException [Error 10044]: line 18:36
Cannot insert into target table because column number/types are different 'test_uniontyp':
Cannot convert column 1 from string to uniontype<array<string>, string,struct<abd:array<struct<ax:string,bx:string>>>>
.


Any suggestion.
0
I am integrating into a webservice, it returns json, here are 2 types of results from it
{"numFound":1,"QTime":77,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":100004730,"lng":36.710459425750635,"lat":-1.336961662155654,"streetName":"Marula Lane","city":"Bulbul","state":"Kajiado","countryCode":"KE","geocodingLevel":"STREET","distance":300.4280656229352,"adm1Name":"Kajiado","formatedFull":"Marula Lane, Bulbul, Kajiado, Kenya","formatedPostal":"Marula Lane, Bulbul","speedMode":"OSM","maxSpeed":"30 mph","azimuthStart":267,"azimuthEnd":251,"length":1161.411457366,"sourceId":33136013}]}



{"numFound":1,"QTime":2537,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":22523950,"lng":36.81669998168945,"lat":-1.2833000421524048,"zipCode":"09831","city":"APO AE","countryCode":"US","geocodingLevel":"CITY","distance":13413.984061400277,"formatedFull":"APO AE,  (09831), United States","formatedPostal":"APO AE, 09831"}]}

Open in new window


I've used the visual studio paste special as JSON class on the first result as that seems to have more info
I'm using the 2nd result as the  test scenario

I then use this code
Result json1 = JsonConvert.DeserializeObject<Result>(jResult);

Open in new window


But all the objects are empty or null

What am I doing wrong?
0
Hello,
My problem is that the "JsonUtility.FromJson" is not working on Android, only works on the Unity Editor.
This is my code:
IEnumerator LoadStreamingAsset(string fileName)
    {
        string result;
        string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, fileName);

        if (filePath.Contains("://") || filePath.Contains(":///"))
        {
            WWW www = new WWW(filePath);
            yield return www;
            result = www.text;
        }
        else
        {
            result = File.ReadAllText(filePath);
        }
        GameData loadedData = JsonUtility.FromJson<GameData >(result);
        Questions = loadedData.Questions ;
        Debug.Log("Loaded file: " + result);
    }

Open in new window


Any help?
0
I have an array of checkboxes coming from a collection.

See below:

<div class="form-group">
    Select days in a week :
    <td class="even" *ngFor="let item of dayList">
    <input value="{{item.check}}" type="checkbox" checked="item.check" formControlName = "selectedDays">  {{item}}
   </div>

Open in new window


formControlName I am set as selectedDays.

I need to generate JSON object for the selected checkbox values.

Currently, i am getting boolean value in selectedDays. But I am supposed to get an array of checked values in an array inside JSON object.

this.dayList = ['Sun', 'Mon', 'Tue','Wed',"Thu","Fri","Sat"];

JSON Object looks like below, please note the value of selectedDays, it is supposed to be "Sun, Mon" based on selection, but it is showing as true.


 
Object
    date
    :
    "2"
    day
    :
    "Mon"
    hour
    :
    "3"
    minute
    :
    "3"
    schedulerjobtype
    :
    "Daily"
    selectedDays
    :
    true
    useCase
    :
    "UC 2"
    zone
    :
    "Zone 3"

Open in new window


How can I implement this?
0
I'm trying to get this json data

https://www.cryptocompare.com/api/data/coinlist/

Here's my code

import axios from 'axios';

axios.get("https://www.cryptocompare.com/api/data/coinlist/")
.then((result) => {
  console.log(result);
}).catch((err) => {
  console.log(err);
});

Open in new window


But I'm getting an error



How this error can be fixed to actually get the data?
0

JSON

751

Solutions

749

Contributors

JavaScript Object Notation, or JSON, is human-readable text used when transmitting data objects consisting of attribute:value pairs between a server and a web application as an alternative to XML. JSON, while it is originally derived from JavaScript, is a language-independent data format. Code for parsing and generating JSON data is available in many programming languages.

Related Topics