I know this question has been asked before and there is a very old post with some details however it is dated and there was some discussion to add this to breeze.
I am using angularJS and a telerik component which doesn't work with breeze entities, i would very much like to convert a breeze entity query list to simple json so that i can map it to my component.
I know there has been mention of ko.toJs() but i do not use knockout. Is there a better method to do this?
Thanks
Use the noTracking EntityQuery method:
From the breeze API docs:
noTracking()
Returns a query with the 'noTracking' capability either enabled or disabled. With 'noTracking' enabled, the results of this query will not be coerced into entities but will instead look like raw javascript projections. i.e. simple javascript objects.
var query = new EntityQuery("Customers")
.take(20)
.orderBy("CompanyName")
.noTracking(true);
Related
i wanted to use Google Apps Scripts to analyze a Google Sheet.
I want to analyze how common certain answers are and wanted to use a map or dictionary to implement this.
My problem is, no suitable datatype seems to work inside Google Apps Script. I also read the tipp to just use objects with a key value, but it doesnt seem like Google Apps Scripts support the values parameter, generally associated with javascript objects.
So are there any types of key-value datastructure, that i can use and that has working functions for giving out the keys or values ?
Are you looking for a datastructure to store and retrieve map type data or is it just for processing?
The PropertiesServices and the CacheServices are the closest to what you are looking for. However, they take only strings as keys and values so you can build a mechanism on top of it to support objects in addition to string values.
You can use this helpful library that was created by github user yinonavraham that supports putting/getting objects in Cache
https://github.com/yinonavraham/GoogleAppsScripts/tree/master/EnhancedCacheService
While yinonavraham has built it for the CacheService, you can easily build an equivalent for the PropertiesService following his lead.
I recently discovered CouchDB and it fits perfectly for what I am working at today. Working with the Futon interface, and calling the http API works fin, but something is missing.
During the design of my application, I sometimes want to apply some changes on all the documents in the database. As a simplified example, lets say all my documents have a field named "type", and I decided to pick strings as type instead of numbers.
Now I have to go over all my documents in Futon, and change the string into a number, which is a silly job.
Another example would be deleting all documents that apply to a certain condition.
The perfect solution would be some kind of engine which can call a javascript function per document, and I can return the new value for the document.
Does this exist?
Everything you need is already there: the API. Note that Futon also only a wrapper around the API.
Not sure what middleware you use (node?, php?) but if you're familiar with the API it should be easy to:
Get all documents
Change field "type" (string instead of number)
Save the docs (use _bulk_docs)
I have some data stored in JSON format. I would like to be able to display it in a browser as a dynamic tree structure in a similar way MongoVUE presents the mondodb documents:
Screenshot
I have found a very nice jquery plugin, called jsTree. Unfortunately, in order to process JSON documents it requires data to have a very specific verbose (and redundant, in my opinion) structure: link. Using it means significant modifications of my json documents. I am rather searching for a tool that is able to build the tree automagically, without making severe manual adjustments to the data, yet allowing me to potentially apply some modifications to the view, if I would need to.
The tool at json.bloople.net makes something similar using a table, but because I have several levels of nested documents, the output looks very bloated. Moreover, the structure is not dynamically collapsible.
I would appreciate any hints regarding the right tools to do the job, including both those that might require (automated!) pre-processing of JSON data in Java/Groovy or pure JavaScript-based solution.
This is just a simple example of how you could output a tree like JSON structure in html. http://jsfiddle.net/K2ZQQ/1/ (see here for browser support for white-space). Note that the second parameter to JSON.stringify is a replacer function:
From http://msdn.microsoft.com/en-us/library/ie/cc836459(v=vs.94).aspx
If replacer is a function, JSON.stringify calls the function, passing
in the key and value of each member. The return value is used instead
of the original value. If the function returns undefined, the member
is excluded. The key for the root object is an empty string: "".
So if you need to add any further modifications to the dislpay of your JSON tree the replacer function may be of help.
I have some identifiers on my page. Named id[0], id[1] all the way to id[20] and sometimes more. I need to send these to an MVC controller and I would like to package them up as one object and unpack at the controller. Can someone tell me if this is possible, my knowledge of javascript is just basic so I'd really appreciate advice on which way to go. For example can I use JSON or serialize. btw I'm using jQuery.
Gordon
You can send your data in JSON.
See > ASP.NET MVC How to pass JSON object from View to Controller as Parameter
If you already have the id array (id[0], id1 , ... id[20]) you can convert it to JSON string with respect of JSON.stringify(id) where JSON.stringify function defined in the json2.js.
On the server side you can use for example Deserialize method of the JavaScriptSerializer to convert the data to List<T> where T is type of id[i] (for example string).
How to send data with respect of jQuery.ajax you already know from another answer.
Is there such a thing as JSON namespaces, just like XML namespaces? Has anyone created a spec or libraries for this? Is this a good or a terrible idea?
I want to make a data spec that can be represented in XML as well as JSON. However I also need the namespace concept, that the data can be extended by annotations in different vocabularies.
To be more specific, this is about representing events. My schema will describe the event in basic terms (time and location), though if you think about it, events can be annotated with different information e.g. attendees or image URLs which I don't want to specify in my schema.
JSON-LD might help :
"JSON-LD (JavaScript Object Notation for Linking Data) is a lightweight Linked Data format that gives your data context."
JSON Schema might be the right thing for this:
http://json-schema.org/
Althought I don't know how well it's implemented.
This is quite an old thread, but there are JSON prefixes, which are almost like namespaces. If you are using Java server-side with Jettison, you can easily meet them.