Giter VIP home page Giter VIP logo

Comments (4)

mb21 avatar mb21 commented on July 20, 2024

This is because AngularJS stores some hidden values with the $-prefix. But it would certainly be possible to prefix all our stuff with, say, _ (so that $asdf is encoded as _$asdf) and then go back and forth between these representations. Pull requests are welcome :)

from jsonedit.

jusio avatar jusio commented on July 20, 2024

Well the only bulletproof (and relatively painless), to deal with problem in my opnion, is not use object structure as model, but create a special model for working with json. E.g after json is parsed, object is not passed into the scope, but is transformed to the following form:

 {
  properties:[{name:"stringProp": value:"stringValue"},
                  {name:"arrayProp": value:[{properties:[]},"stringItem",1]  }
  ]   
}

Such model corresponds to the following JSON

{
   "stringProp":"stringValue",
   "arrayProp":[{},"stringItem",1]
}

If you pass such model into scope, it doesn't matter which keys angular adds later, because you interested only in specific keys. You can use also some escaping, but i believe it is way too error prone.

from jsonedit.

mb21 avatar mb21 commented on July 20, 2024

What's so error prone about this: prefixing each key with a _ when reading from the text area, removing the first char (i.e. the _) when writing back from the Angular model to the textarea.

from jsonedit.

jusio avatar jusio commented on July 20, 2024

Well I think it is simply cleaner, since you don't have to always remember that correct keys should have '_' prefix (at least you have to add it in key name editor/render, may be there some other places).

But the is definitely choice is yours, I'm just suggesting since I had to do something similar in the past, tried to use escaping at first, then I said screw it, and just implemented using special model structure and in the end it was much easier.

from jsonedit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.