json

get the item from json fixture in Python

I have json like that: [ { fields: { username: “andriy”, first_name: “”, last_name: “”, is_active: true, is_superuser: true, is_staff: true, last_login: “2015-03-26T13:20:01.902Z”, groups: [ ], user_permissions: [ ], password: “pbkdf2_sha256$12000$YluCbMyidWwL$yH”, email: “”, date_joined: “2015-03-26T13:19:23.269Z” }, model: “auth.user”, pk: 4 }, and try to get value of item ‘username’: import json from collections import OrderedDict from django.http import HttpResponse path…
Read more

How to convert multi-dimensional json to nested POST fields

Is there any plugin or function that converts multi-dimensional JSON like this: { “hello” : { “foo” : “bar”, “arr” : [“a”, “b”, “c”] }, “another”: { “go” : { “very” : { “deep” : 1 } } } } To array in this format [ {“key” : “another[go][very][deep]”, “value” : “1”), {“key” : “hello[arr][]”, “value” :a”), {“key” : “hello[arr][]”,…
Read more

how inadvertently adding UTF8 format while copy paste?

I have a string with non uft8 format $str = Processing’s; following json_encode works fine because i’m copying and pasting code to my editor $str = Processing’s; echo json_encode($str); output: Processingu2019s” if i retrive the same string Processing’s from DB and do json_encode it returns NULL because of it is non UTF8 string. How when I copy paste code works…
Read more

How to use file_get_contents on loop?

I’m trying to use file_get_contents on loop, in order to fetch JSON string from an URL continuously (every second). And i need to store the result into a javascript variable. Here was my approach, but i didn’t get any result from this. My page showed me nothing but endless loading. <?php set_time_limit(0); while(true) { $jsonContent=file_get_contents(‘http://megarkarsa.com/gpsjson.php’); echo $jsonContent; sleep(10); } ?>…
Read more

Error analysing json file with python

I have a json file (defined as k in my code) that has multiple levels within it I’m trying to analyse and am getting an error I’m having trouble understanding. Here is my code as it is: for i in k: if ‘pens’ in k[i]: print i+” “+str(k[i][‘pens’][‘Papermate’][‘Total Quantity’]) I am getting KeyError: ‘Papermate’ when it has reached a person…
Read more

js Array undefined after json declaration

I m new a web developer and i face up the following problem: “Cannot read property ‘length’ of undefined” my code: var data=(); for(var i;i<parseInt(window.localStorage[“numOfInserts”]);i++){ data[“category_name”]=localStorage.getItem((“category_name_”+i).toString()); data[“category_id”]=localStorage.getItem((“category_id_”+i).toString()); data[“provider_name”]=localStorage.getItem((“provider_name_”+i).toString()); data[“provider_id”]=localStorage.getItem((“provider_id_”+i).toString()); data[“appointment_date”]=localStorage.getItem((“appointment_date_”+i).toString()); data[“appointment_time”]=localStorage.getItem((“appointment_time_”+i).toString()); } $scope.allAppointments=dataArray; for(var i=0;i<dataArray.length;i++){ $scope.showme[i]=false; } After some research I understand that the problem caused to the fact that data is an array but I try to turn it…
Read more

how to transform jArray into jobject

I’m using Newtonsoft.Json lib with C# and encountered a problem. I have a jArray as below: [{“category”: “computer”,”subcat”: “desktop”}, {“category”: “category”,”subcat”: “laptop”}, {“category”: “television”,”subcat”: “LCD”}] and I want it to be transformed as a jObject as below: {“computer”: [“desktop”,”laptop”], “television”: [“LCD”]} Here want I need is a general method that can handle this type of transformation. Which means this method…
Read more

Insert json data to db in codeigniter

I have to insert a json data to the db using codeigniter.But i have some insertion issue.. controller $other_details=array($last_gradel,$years_studied,$school_name,$school_town,$school_district,$school_state,$school_country, $school_tel_no,$school_mob_no,$school_email,$third_lang,$outstanding_achieve); $application_insert = $this->career->insert_student_application($other_details); $status[‘result’] = “ok”; echo json_encode($status); model function insert_student_application($other_details) { $data_insert = array( ‘applicant_prev_grade’ => $other_details[0], ‘years_last_school’ => $other_details[1], ‘school_name’ => $other_details[2], ‘school_town’ => $other_details[3], ‘school_district’ => $other_details[4], ‘school_state’ => $other_details[5], ‘school_country’ => $other_details[6], ‘school_tel_number’ => $other_details[7], ‘school_mob_number’…
Read more

JsonPathParsingFailure when posting JSON Web Token through Retrofit with OkHttpClient

I’m trying to send JSON Web Token (JWT) to REST service but I’m getting this error: D/Retrofit﹕ {“fault”:{“faultstring”:”ExtractVariables ExtractVariables.BpExtractVATNumberJSON: Json path parsing failed for for flow variables copy.payload”,”detail”:{“errorcode”:”steps.extractvariables.JsonPathParsingFailure”}}} I can’t find any clue, what could cause this problem. My JWT looks fine Service definition I use: @Headers(“Content-Type: application/json; charset=UTF-8”) @POST(“/v1/cash_registers/invoices/register”) Token registerBusinessPremise(@Body Token premiseToken); JWT looks like this: {“token” :…
Read more